linux/drivers/net/dsa
Daniel Golle bcb3b83146 net: dsa: mxl862xx: fix use-after-free of DSA ports in crc_err_work
Upon an MDIO CRC error mxl862xx_crc_err_work_fn() walks the DSA ports
and closes the CPU port conduits:

	dsa_switch_for_each_cpu_port(dp, priv->ds)
		dev_close(dp->conduit);

mxl862xx_remove() unregisters the switch before cancelling this work:

	set_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags);
	cancel_delayed_work_sync(&priv->stats_work);
	dsa_unregister_switch(ds);
	mxl862xx_host_shutdown(priv);

dsa_unregister_switch() frees the dsa_port objects. If a CRC error
schedules the work during teardown it can run after the ports have been
freed and dereference freed memory.

Guard the port walk with MXL862XX_FLAG_WORK_STOPPED, which is already set
before dsa_unregister_switch(). DSA tears the ports down under
rtnl_lock(), so checking the flag under rtnl_lock() means the work either
runs before teardown and sees valid ports, or runs afterwards, observes
the flag and skips the walk. This mirrors the host_flood_work handler,
which skips torn-down ports under rtnl_lock().

Link: https://sashiko.dev/#/patchset/cover.1780968180.git.daniel%40makrotopia.org?part=2
Fixes: a319d0c8c8 ("net: dsa: mxl862xx: add CRC for MDIO communication")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Link: https://patch.msgid.link/5e55169926c02f2b914e5ada529d7453b943cda4.1781702256.git.daniel@makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-24 17:51:11 -07:00
..
b53 net: dsa: b53: avoid devlink resource IDs collision with PARENT_TOP 2026-06-15 12:41:40 -07:00
hirschmann net: dsa: hellcreek: avoid devlink resource IDs collision with PARENT_TOP 2026-06-15 12:41:40 -07:00
lantiq net: dsa: mxl-gsw1xx: validate chip ID 2026-02-10 09:09:27 +01:00
microchip net: dsa: microchip: implement port_teardown only if needed 2026-06-12 18:08:08 -07:00
mv88e6xxx net: dsa: mv88e6xxx: Avoid devlink resource IDs collision with PARENT_TOP 2026-06-15 12:41:41 -07:00
mxl862xx net: dsa: mxl862xx: fix use-after-free of DSA ports in crc_err_work 2026-06-24 17:51:11 -07:00
netc net: dsa: netc: implement dynamic FDB entry ageing 2026-06-15 14:32:06 -07:00
ocelot net: mscc: ocelot: validate netdev belongs to switch in .netdev_to_port() 2026-06-09 17:54:34 -07:00
qca Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-06-16 14:59:58 -07:00
realtek net: dsa: realtek: fix memory leak in rtl8366rb_setup_led() 2026-06-24 17:46:18 -07:00
sja1105 net: dsa: sja1105: round up PTP perout pin duration 2026-06-23 14:42:38 -07:00
xrs700x net: dsa: Use named initializers for struct i2c_device_id 2026-05-20 19:01:25 -07:00
bcm_sf2_cfp.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
bcm_sf2_regs.h
bcm_sf2.c net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths 2026-03-19 09:26:40 -07:00
bcm_sf2.h net: dsa: use ethtool string helpers 2024-11-03 10:36:34 -08:00
dsa_loop.c net: dsa: dsa_loop: avoid devlink resource IDs collision with PARENT_TOP 2026-06-15 12:41:40 -07:00
Kconfig net: dsa: netc: introduce NXP NETC switch driver for i.MX94 2026-05-21 13:04:42 +02:00
ks8995.c net: dsa: ks8995: Fix incorrect OF match table name 2025-11-18 18:22:04 -08:00
lan9303_i2c.c net: dsa: Use named initializers for struct i2c_device_id 2026-05-20 19:01:25 -07:00
lan9303_mdio.c dsa: lan9303: consistent naming for PHY address parameter 2024-07-15 08:49:59 -07:00
lan9303-core.c net: dsa: lan9303: ensure chip reset and wait for READY status 2024-10-07 16:38:02 -07:00
lan9303.h
Makefile net: dsa: netc: introduce NXP NETC switch driver for i.MX94 2026-05-21 13:04:42 +02:00
mt7530-mdio.c net: pcs: pcs-mtk-lynxi: pass SGMIISYS OF node to PCS 2026-01-21 19:46:58 -08:00
mt7530-mmio.c net: dsa: mt7530: Constify struct regmap_config 2025-07-13 22:28:56 +01:00
mt7530.c net: dsa: mt7530: untag VLAN-aware bridge PVID 2026-05-19 12:37:34 +02:00
mt7530.h net: dsa: mt7530: fix .get_stats64 sleeping in atomic context 2026-05-04 19:28:54 -07:00
mv88e6060.c net: dsa: mv88e6060: use simple HSR offload helpers 2025-12-01 16:45:08 -08:00
mv88e6060.h
rzn1_a5psw.c net: dsa: a5psw: use simple HSR offload helpers 2025-12-01 16:45:08 -08:00
rzn1_a5psw.h net: dsa: rzn1-a5psw: add vlan support 2023-08-11 11:58:36 +01:00
vitesse-vsc73xx-core.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vitesse-vsc73xx-platform.c net: dsa: Switch back to struct platform_driver::remove() 2024-10-04 16:39:57 -07:00
vitesse-vsc73xx-spi.c
vitesse-vsc73xx.h net: dsa: vsc73xx: implement FDB operations 2024-09-03 10:22:58 +02:00
yt921x.c net: dsa: yt921x: Add ACL support 2026-06-10 08:26:05 -07:00
yt921x.h net: dsa: yt921x: Add ACL support 2026-06-10 08:26:05 -07:00