]> git.baikalelectronics.ru Git - kernel.git/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:28:09 +0000 (12:28 +0200)
commite74bd1b229cb16ce078fc36177c6d6dcdf28d160
treeb11bd71d30d356da80a89c7a9c31c622bcc6a334
parentd766cf9ddb9714b373fcb86e437e54dcf232c3cc
net: dsa: sja1105: serialize sja1105_port_mcast_flood() with other FDB accesses

[ Upstream commit ea32690daf4fa525dc5a4d164bd00ed8c756e1c6 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/sja1105/sja1105.h
drivers/net/dsa/sja1105/sja1105_main.c