linux-stable/net/dsa
Vladimir Oltean d44f5ffa36 net: dsa: flush switchdev workqueue on bridge join error path
[ Upstream commit 630fd4822a ]

There is a race between switchdev_bridge_port_offload() and the
dsa_port_switchdev_sync_attrs() call right below it.

When switchdev_bridge_port_offload() finishes, FDB entries have been
replayed by the bridge, but are scheduled for deferred execution later.

However dsa_port_switchdev_sync_attrs -> dsa_port_can_apply_vlan_filtering()
may impose restrictions on the vlan_filtering attribute and refuse
offloading.

When this happens, the delayed FDB entries will dereference dp->bridge,
which is a NULL pointer because we have stopped the process of
offloading this bridge.

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
Workqueue: dsa_ordered dsa_slave_switchdev_event_work
pc : dsa_port_bridge_host_fdb_del+0x64/0x100
lr : dsa_slave_switchdev_event_work+0x130/0x1bc
Call trace:
 dsa_port_bridge_host_fdb_del+0x64/0x100
 dsa_slave_switchdev_event_work+0x130/0x1bc
 process_one_work+0x294/0x670
 worker_thread+0x80/0x460
---[ end trace 0000000000000000 ]---
Error: dsa_core: Must first remove VLAN uppers having VIDs also present in bridge.

Fix the bug by doing what we do on the normal bridge leave path as well,
which is to wait until the deferred FDB entries complete executing, then
exit.

The placement of dsa_flush_workqueue() after switchdev_bridge_port_unoffload()
guarantees that both the FDB additions and deletions on rollback are waited for.

Fixes: d7d0d423db ("net: dsa: flush switchdev workqueue when leaving the bridge")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20220507134550.1849834-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-05-18 10:28:14 +02:00
..
Kconfig net: dsa: tag_rtl8_4: add realtek 8 byte protocol 4 tag 2021-10-18 14:02:56 +01:00
Makefile net: dsa: tag_rtl8_4: add realtek 8 byte protocol 4 tag 2021-10-18 14:02:56 +01:00
dsa.c net: dsa: mv88e6xxx: flush switchdev FDB workqueue before removing VLAN 2022-02-14 13:31:12 +00:00
dsa2.c Revert "net: dsa: setup master before ports" 2022-04-20 09:36:27 +02:00
dsa_priv.h net: dsa: mv88e6xxx: flush switchdev FDB workqueue before removing VLAN 2022-02-14 13:31:12 +00:00
master.c Revert "net: dsa: stop updating master MTU from master.c" 2022-04-13 19:27:28 +02:00
port.c net: dsa: flush switchdev workqueue on bridge join error path 2022-05-18 10:28:14 +02:00
slave.c net: dsa: merge rtnl_lock sections in dsa_slave_create 2022-01-06 11:59:09 +00:00
switch.c net: dsa: Avoid cross-chip syncing of VLAN filtering 2022-04-08 13:57:58 +02:00
tag_8021q.c net: dsa: keep the bridge_dev and bridge_num as part of the same structure 2021-12-08 14:31:16 -08:00
tag_ar9331.c
tag_brcm.c
tag_dsa.c net: dsa: hide dp->bridge_dev and dp->bridge_num in the core behind helpers 2021-12-08 14:31:15 -08:00
tag_gswip.c
tag_hellcreek.c net: dsa: hellcreek: Calculate checksums in tagger 2022-04-27 14:41:02 +02:00
tag_ksz.c
tag_lan9303.c net: dsa: lan9303: handle hwaccel VLAN tags 2022-02-17 09:32:06 -08:00
tag_mtk.c
tag_ocelot.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-12-23 16:09:58 -08:00
tag_ocelot_8021q.c net: dsa: make tagging protocols connect to individual switches from a tree 2021-12-14 12:45:16 +00:00
tag_qca.c
tag_rtl4_a.c
tag_rtl8_4.c net: dsa: tag_rtl8_4: add realtek 8 byte protocol 4 tag 2021-10-18 14:02:56 +01:00
tag_sja1105.c net: dsa: make tagging protocols connect to individual switches from a tree 2021-12-14 12:45:16 +00:00
tag_trailer.c
tag_xrs700x.c