linux/net/8021q
Di Zhu c1102e9d49 net: fix a data race when get vlan device
We encountered a crash: in the packet receiving process, we got an
illegal VLAN device address, but the VLAN device address saved in vmcore
is correct. After checking the code, we found a possible data
competition:
CPU 0:                             CPU 1:
    (RCU read lock)                  (RTNL lock)
    vlan_do_receive()		       register_vlan_dev()
      vlan_find_dev()

        ->__vlan_group_get_device()	 ->vlan_group_prealloc_vid()

In vlan_group_prealloc_vid(), We need to make sure that memset()
in kzalloc() is executed before assigning  value to vlan devices array:
=================================
kzalloc()
    ->memset(object, 0, size)

smp_wmb()

vg->vlan_devices_arrays[pidx][vidx] = array;
==================================

Because __vlan_group_get_device() function depends on this order.
otherwise we may get a wrong address from the hardware cache on
another cpu.

So fix it by adding memory barrier instruction to ensure the order
of memory operations.

Signed-off-by: Di Zhu <zhudi21@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-04-19 16:08:03 -07:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile net: remove blank lines at end of file 2018-07-24 14:10:43 -07:00
vlan.c net: fix a data race when get vlan device 2021-04-19 16:08:03 -07:00
vlan.h net: fix a data race when get vlan device 2021-04-19 16:08:03 -07:00
vlan_core.c net: vlan: suppress "failed to kill vid" warnings 2020-02-17 14:30:54 -08:00
vlan_dev.c net: vlan: Add parse protocol header ops 2021-01-14 18:24:53 -08:00
vlan_gvrp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
vlan_mvrp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
vlan_netlink.c vlan: vlan_changelink() should propagate errors 2020-01-07 13:35:14 -08:00
vlanproc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
vlanproc.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00