From: Raj Ojha <rajojha047@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org,
syzbot+e9cbd080a7801f06cf08@syzkaller.appspotmail.com,
Raj Ojha <rajojha047@gmail.com>
Subject: [PATCH] wifi: mac80211: acquire wiphy lock for unlisted sdata teardown
Date: Sat, 3 Oct 2026 16:57:41 +0530 [thread overview]
Message-ID: <20261003112741.52-1-rajojha047@gmail.com> (raw)
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
reply other threads:[~2026-10-03 11:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261003112741.52-1-rajojha047@gmail.com \
--to=rajojha047@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=syzbot+e9cbd080a7801f06cf08@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox