linux-stable/drivers/net/dsa
Vladimir Oltean 4c46bb4946 net: dsa: felix: suppress non-changes to the tagging protocol
The way in which dsa_tree_change_tag_proto() works is that when
dsa_tree_notify() fails, it doesn't know whether the operation failed
mid way in a multi-switch tree, or it failed for a single-switch tree.
So even though drivers need to fail cleanly in
ds->ops->change_tag_protocol(), DSA will still call dsa_tree_notify()
again, to restore the old tag protocol for potential switches in the
tree where the change did succeeed (before failing for others).

This means for the felix driver that if we report an error in
felix_change_tag_protocol(), we'll get another call where proto_ops ==
old_proto_ops. If we proceed to act upon that, we may do unexpected
things. For example, we will call dsa_tag_8021q_register() twice in a
row, without any dsa_tag_8021q_unregister() in between. Then we will
actually call dsa_tag_8021q_unregister() via old_proto_ops->teardown,
which (if it manages to run at all, after walking through corrupted data
structures) will leave the ports inoperational anyway.

The bug can be readily reproduced if we force an error while in
tag_8021q mode; this crashes the kernel.

echo ocelot-8021q > /sys/class/net/eno2/dsa/tagging
echo edsa > /sys/class/net/eno2/dsa/tagging # -EPROTONOSUPPORT

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000014
Call trace:
 vcap_entry_get+0x24/0x124
 ocelot_vcap_filter_del+0x198/0x270
 felix_tag_8021q_vlan_del+0xd4/0x21c
 dsa_switch_tag_8021q_vlan_del+0x168/0x2cc
 dsa_switch_event+0x68/0x1170
 dsa_tree_notify+0x14/0x34
 dsa_port_tag_8021q_vlan_del+0x84/0x110
 dsa_tag_8021q_unregister+0x15c/0x1c0
 felix_tag_8021q_teardown+0x16c/0x180
 felix_change_tag_protocol+0x1bc/0x230
 dsa_switch_event+0x14c/0x1170
 dsa_tree_change_tag_proto+0x118/0x1c0

Fixes: 7a29d220f4 ("net: dsa: felix: reimplement tagging protocol change with function pointers")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220808125127.3344094-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-08-09 12:13:03 -07:00
..
b53 net: dsa: b53: remove unnecessary spi_set_drvdata() 2022-07-06 19:49:59 -07:00
hirschmann net: dsa: hellcreek: Use the bitmap API to allocate bitmaps 2022-07-11 19:49:20 -07:00
microchip net: dsa: microchip: add support for phylink mac config 2022-07-27 09:39:17 +01:00
mv88e6xxx net: dsa: mv88e6xxx: fix speed setting for CPU/DSA ports 2022-07-27 19:58:34 -07:00
ocelot net: dsa: felix: suppress non-changes to the tagging protocol 2022-08-09 12:13:03 -07:00
qca net: dsa: qca8k: move read_switch_id function to common code 2022-07-28 22:24:40 -07:00
realtek net: dsa: realtek: rtl8365mb: handle PHY interface modes correctly 2022-06-16 20:44:47 -07:00
sja1105 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-21 13:03:39 -07:00
xrs700x net: dsa: pass extack to .port_bridge_join driver methods 2022-02-27 11:06:14 +00:00
Kconfig net: dsa: qca8k: move driver to qca dir 2022-07-15 11:57:13 +01:00
Makefile net: dsa: qca8k: move driver to qca dir 2022-07-15 11:57:13 +01:00
bcm_sf2.c net: dsa: bcm_sf2: force pause link settings 2022-06-23 20:46:39 -07:00
bcm_sf2.h net: dsa: bcm_sf2: refactor LED regs access 2021-12-30 17:28:32 -08:00
bcm_sf2_cfp.c net: dsa: bcm_sf2_cfp: fix an incorrect NULL check on list iterator 2022-03-28 14:38:38 -07:00
bcm_sf2_regs.h net: dsa: bcm_sf2: refactor LED regs access 2021-12-30 17:28:32 -08:00
dsa_loop.c net: dsa: pass extack to .port_bridge_join driver methods 2022-02-27 11:06:14 +00:00
dsa_loop.h
dsa_loop_bdinfo.c
lan9303-core.c net: dsa: pass extack to .port_bridge_join driver methods 2022-02-27 11:06:14 +00:00
lan9303.h net: dsa: be compatible with masters which unregister on shutdown 2021-09-19 12:08:37 +01:00
lan9303_i2c.c net: dsa: be compatible with masters which unregister on shutdown 2021-09-19 12:08:37 +01:00
lan9303_mdio.c net: dsa: be compatible with masters which unregister on shutdown 2021-09-19 12:08:37 +01:00
lantiq_gswip.c net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list 2022-06-07 20:45:14 -07:00
lantiq_pce.h
mt7530.c net: dsa: mt7530: get cpu-port via dp->cpu_dp instead of constant 2022-06-14 22:35:16 -07:00
mt7530.h net: dsa: mt7530: get cpu-port via dp->cpu_dp instead of constant 2022-06-14 22:35:16 -07:00
mv88e6060.c net: dsa: be compatible with masters which unregister on shutdown 2021-09-19 12:08:37 +01:00
mv88e6060.h
rzn1_a5psw.c net: dsa: rzn1-a5psw: add missing of_node_put() in a5psw_pcs_get() 2022-06-30 21:07:03 -07:00
rzn1_a5psw.h net: dsa: rzn1-a5psw: add FDB support 2022-06-27 11:37:55 +01:00
vitesse-vsc73xx-core.c net: dsa: vsc73xxx: Get rid of duplicate of_node assignment 2021-12-03 14:13:02 +00:00
vitesse-vsc73xx-platform.c net: dsa: be compatible with masters which unregister on shutdown 2021-09-19 12:08:37 +01:00
vitesse-vsc73xx-spi.c net: dsa: vitesse-vsc73xx: silent spi_device_id warnings 2022-07-19 12:20:40 +02:00
vitesse-vsc73xx.h net: dsa: vsc73xxx: Make vsc73xx_remove() return void 2021-11-15 13:15:07 +00:00