]> git.itanic.dy.fi Git - linux-stable/commit
net: dsa: sja1105: serialize sja1105_port_mcast_flood() with other FDB accesses
authorVladimir Oltean <vladimir.oltean@nxp.com>
Fri, 8 Sep 2023 13:33:51 +0000 (16:33 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Sep 2023 07:32:30 +0000 (08:32 +0100)
commitea32690daf4fa525dc5a4d164bd00ed8c756e1c6
treece77f5a664ba06db4cbcb5a5e09161719c33633e
parent7cef293b9a634a05fcce9e1df4aee3aeed023345
net: dsa: sja1105: serialize sja1105_port_mcast_flood() with other FDB accesses

sja1105_fdb_add() runs from the dsa_owq, and sja1105_port_mcast_flood()
runs from switchdev_deferred_process_work(). Prior to the blamed commit,
they used to be indirectly serialized through the rtnl_lock(), which
no longer holds true because dsa_owq dropped that.

So, it is now possible that we traverse the static config BLK_IDX_L2_LOOKUP
elements concurrently compared to when we change them, in
sja1105_static_fdb_change(). That is not ideal, since it might result in
data corruption.

Introduce a mutex which serializes accesses to the hardware FDB and to
the static config elements for the L2 Address Lookup table.

I can't find a good reason to add locking around sja1105_fdb_dump().
I'll add it later if needed.

Fixes: 0faf890fc519 ("net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105.h
drivers/net/dsa/sja1105/sja1105_main.c