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 <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-10-11 11:31:27 +02:00
parent 79976044e4
commit 9a8407984a
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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