mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
11fd667dac
It is said that as soon as a network interface is registered, all its resources should have already been prepared, so that it is available for sending and receiving traffic. One of the resources needed by a DSA slave interface is the master. dsa_tree_setup -> dsa_tree_setup_ports -> dsa_port_setup -> dsa_slave_create -> register_netdevice -> dsa_tree_setup_master -> dsa_master_setup -> sets up master->dsa_ptr, which enables reception Therefore, there is a short period of time after register_netdevice() during which the master isn't prepared to pass traffic to the DSA layer (master->dsa_ptr is checked by eth_type_trans). Same thing during unregistration, there is a time frame in which packets might be missed. Note that this change opens us to another race: dsa_master_find_slave() will get invoked potentially earlier than the slave creation, and later than the slave deletion. Since dp->slave starts off as a NULL pointer, the earlier calls aren't a problem, but the later calls are. To avoid use-after-free, we should zeroize dp->slave before calling dsa_slave_destroy(). In practice I cannot really test real life improvements brought by this change, since in my systems, netdevice creation races with PHY autoneg which takes a few seconds to complete, and that masks quite a few races. Effects might be noticeable in a setup with fixed links all the way to an external system. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net> |
||
---|---|---|
.. | ||
dsa.c | ||
dsa2.c | ||
dsa_priv.h | ||
Kconfig | ||
Makefile | ||
master.c | ||
port.c | ||
slave.c | ||
switch.c | ||
tag_8021q.c | ||
tag_ar9331.c | ||
tag_brcm.c | ||
tag_dsa.c | ||
tag_gswip.c | ||
tag_hellcreek.c | ||
tag_ksz.c | ||
tag_lan9303.c | ||
tag_mtk.c | ||
tag_ocelot.c | ||
tag_ocelot_8021q.c | ||
tag_qca.c | ||
tag_rtl4_a.c | ||
tag_rtl8_4.c | ||
tag_sja1105.c | ||
tag_trailer.c | ||
tag_xrs700x.c |