switchdev: Require RTNL mutex to be held when sending FDB notifications
authorIdo Schimmel <idosch@mellanox.com>
Wed, 27 Jan 2016 14:16:43 +0000 (15:16 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 29 Jan 2016 00:21:31 +0000 (16:21 -0800)
commit4f2c6ae5c64c353fb1b0425e4747e5603feadba1
tree75e57cd0d11cd1cd39eb12784472b1aff6537242
parent7d0105b5334b9722b7d33acad613096dfcf3330e
switchdev: Require RTNL mutex to be held when sending FDB notifications

When switchdev drivers process FDB notifications from the underlying
device they resolve the netdev to which the entry points to and notify
the bridge using the switchdev notifier.

However, since the RTNL mutex is not held there is nothing preventing
the netdev from disappearing in the middle, which will cause
br_switchdev_event() to dereference a non-existing netdev.

Make switchdev drivers hold the lock at the beginning of the
notification processing session and release it once it ends, after
notifying the bridge.

Also, remove switchdev_mutex and fdb_lock, as they are no longer needed
when RTNL mutex is held.

Fixes: 03bf0c281234 ("switchdev: introduce switchdev notifier")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
drivers/net/ethernet/rocker/rocker.c
net/bridge/br.c
net/switchdev/switchdev.c