From 9a8407984ab43a70174e5474946ab6c19dc2e0ba Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 11 Oct 2026 11:31:27 +0200 Subject: [PATCH] wifi: cfg80211: switch wiphy netns under cfg80211_mutex Hold the cfg80211_mutex across the whole netns switch, so we can walk the wiphy list without worrying about a wiphy switching away to a different namespace underneath. This will allow removing RTNL from netlink dumps. Link: https://patch.msgid.link/20261011113308.89f391aea519.I7529b9055f522cfeb8a26ae3a85c1b71a98e8192@changeid Signed-off-by: Johannes Berg --- net/wireless/core.c | 3 +++ net/wireless/core.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/net/wireless/core.c b/net/wireless/core.c index 777f48a01101..ea38b22a88cd 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -171,6 +171,9 @@ static int __cfg80211_switch_netns(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev, *tmp; int err = 0; + /* make the whole switch atomic for cfg80211_mutex holders, e.g. dumps */ + guard(mutex)(&cfg80211_mutex); + list_for_each_entry_safe(wdev, tmp, &rdev->wiphy.wdev_list, list) { err = cfg80211_switch_wdev_netns(wdev, net); if (!err) diff --git a/net/wireless/core.h b/net/wireless/core.h index 07d7a68a7cfc..e70a4f679bf5 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -20,7 +20,7 @@ #include "reg.h" -/* protects the wiphy list and regulatory state */ +/* protects the wiphy list, wiphy netns changes and regulatory state */ extern struct mutex cfg80211_mutex; #define WIPHY_IDX_INVALID -1