From: Johannes Berg 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. 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 01b077909179..d648df6b8037 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 dfcb9ed5035b..d327c7f4fc12 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -19,7 +19,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 -- 2.56.0