Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] wifi: mac80211: acquire wiphy lock for unlisted sdata teardown
@ 2026-10-03 11:27 Raj Ojha
  0 siblings, 0 replies; only message in thread
From: Raj Ojha @ 2026-10-03 11:27 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, syzbot+e9cbd080a7801f06cf08, Raj Ojha

When netdev registration fails or an interface cannot be moved out of a
dying network namespace, the netdev core calls ->ndo_uninit()
(ieee80211_uninit) with RTNL held.

However, ieee80211_uninit() calls ieee80211_teardown_sdata() without
holding wiphy_lock. During teardown, ieee80211_free_keys() invokes
wiphy_delayed_work_cancel(), which triggers a lockdep warning:

  WARNING: CPU: 0 PID: 6112 at net/wireless/core.c:1839 wiphy_delayed_work_cancel+0x85/0xb0
  ...
  Call Trace:
   ieee80211_free_keys+0x31a/0x3c0 net/mac80211/key.c:380
   ieee80211_teardown_sdata+0x2b8/0x10f0 net/mac80211/iface.c:928
   ieee80211_uninit+0x3f/0x50 net/mac80211/iface.c:954
   rollback_registered_many+0xa5c/0xef0 net/core/dev.c:10065

In the normal deletion path (ieee80211_del_virtual_intf), both RTNL and
wiphy_lock are held when ieee80211_teardown_sdata() runs, and the sdata
is removed from local->interfaces.

Change ieee80211_unlist_sdata() to return a boolean indicating whether the
sdata was present in the list, and acquire wiphy_lock in ieee80211_uninit()
only if the interface is actually being unlisted here.

Reported-by: syzbot+e9cbd080a7801f06cf08@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e9cbd080a7801f06cf08
Tested-by: syzbot+e9cbd080a7801f06cf08@syzkaller.appspotmail.com
Signed-off-by: Raj Ojha <rajojha047@gmail.com>
---
 net/mac80211/iface.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 5f0c482..175965f 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -931,7 +931,7 @@ static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata)
  * core when cfg80211 couldn't move it out of a network namespace that's being
  * destroyed. Drop it from the interface list either way.
  */
-static void ieee80211_unlist_sdata(struct ieee80211_sub_if_data *sdata)
+static bool ieee80211_unlist_sdata(struct ieee80211_sub_if_data *sdata)
 {
 	struct ieee80211_local *local = sdata->local;
 	struct ieee80211_sub_if_data *iter;
@@ -943,16 +943,25 @@ static void ieee80211_unlist_sdata(struct ieee80211_sub_if_data *sdata)
 			continue;
 		guard(mutex)(&local->iflist_mtx);
 		list_del_rcu(&sdata->list);
-		return;
+		return true;
 	}
+
+	return false;
 }
 
 static void ieee80211_uninit(struct net_device *dev)
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct wiphy *wiphy = sdata->local->hw.wiphy;
+	bool unlisted = ieee80211_unlist_sdata(sdata);
+
+	if (unlisted)
+		wiphy_lock(wiphy);
 
-	ieee80211_unlist_sdata(sdata);
 	ieee80211_teardown_sdata(sdata);
+
+	if (unlisted)
+		wiphy_unlock(wiphy);
 }
 
 static int ieee80211_netdev_setup_tc(struct net_device *dev,
-- 
2.47.0.windows.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-03 11:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-03 11:27 [PATCH] wifi: mac80211: acquire wiphy lock for unlisted sdata teardown Raj Ojha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox