cfg80211: fix netdev registration deadlock
authorJohannes Berg <johannes.berg@intel.com>
Mon, 1 Feb 2021 18:20:50 +0000 (19:20 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 1 Feb 2021 18:30:54 +0000 (19:30 +0100)
commit40c575d1ec71f7a61c73ba1603a69650c130559c
treefd01bc1a23dd89442544f2e9e56dd13269cdb00f
parent776a39b8196dbca4afb69669db0d9926ffac29ab
cfg80211: fix netdev registration deadlock

If register_netdevice() fails after having called cfg80211's
netdev notifier (cfg80211_netdev_notifier_call) it will call
the notifier again with UNREGISTER. This would then lock the
wiphy mutex because we're marked as registered, which causes
a deadlock.

Fix this by separately keeping track of whether or not we're
in the middle of registering to also skip the notifier call
on this unregister.

Reported-by: syzbot+2ae0ca9d7737ad1a62b7@syzkaller.appspotmail.com
Fixes: a05829a7222e ("cfg80211: avoid holding the RTNL when calling the driver")
Link: https://lore.kernel.org/r/20210201192048.ed8bad436737.I7cae042c44b15f80919a285799a15df467e9d42d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/wireless/core.c