nl80211: fix locking for wireless device netns change
authorJohannes Berg <johannes.berg@intel.com>
Wed, 10 Mar 2021 20:58:40 +0000 (21:58 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 16 Mar 2021 20:20:47 +0000 (21:20 +0100)
commit77cbf790e5b482256662e14c8b6ef4fecb07d06d
treec99bf77a8a0633a62945edf50067dd724e94a0d1
parent58d25626f6f0ea5bcec3c13387b9f835d188723d
nl80211: fix locking for wireless device netns change

We have all the network interfaces marked as netns-local
since the only reasonable thing to do right now is to set
a whole device, including all netdevs, into a different
network namespace. For this reason, we also have our own
way of changing the network namespace.

Unfortunately, the RTNL locking changes broke this, and
it now results in many RTNL assertions. The trivial fix
for those (just hold RTNL for the changes) however leads
to deadlocks in the cfg80211 netdev notifier.

Since we only need the wiphy, and that's still protected
by the RTNL, add a new NL80211_FLAG_NO_WIPHY_MTX flag to
the nl80211 ops and use it to _not_ take the wiphy mutex
but only the RTNL. This way, the notifier does all the
work necessary during unregistration/registration of the
netdevs from the old and in the new namespace.

Reported-by: Sid Hayn <sidhayn@gmail.com>
Fixes: a05829a7222e ("cfg80211: avoid holding the RTNL when calling the driver")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/20210310215839.eadf7c43781b.I5fc6cf6676f800ab8008e03bbea9c3349b02d804@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/nl80211.c