diff mbox series

[NET-PREV,49/51] ieee802154: Call dev_change_net_namespace() under nd_lock

Message ID 174265463731.356712.9731171337027251381.stgit@pro.pro (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Kill rtnl_lock using fine-grained nd_lock | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply, async

Commit Message

Kirill Tkhai March 22, 2025, 2:43 p.m. UTC
We want to provide "nd_lock is locked" context during
NETDEV_REGISTER (and later for NETDEV_UNREGISTER)
events. When calling from __register_netdevice(),
notifiers are already in that context, and we do the
same for dev_change_net_namespace() here.

Signed-off-by: Kirill Tkhai <tkhai@ya.ru>
---
 net/ieee802154/core.c     |    2 ++
 net/ieee802154/nl802154.c |    1 +
 2 files changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index 60e8fff1347e..8a85a57bf042 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -349,10 +349,12 @@  static void __net_exit cfg802154_pernet_exit(struct net *net)
 	struct cfg802154_registered_device *rdev;
 
 	rtnl_lock();
+	mutex_lock(&fallback_nd_lock.mutex);
 	list_for_each_entry(rdev, &cfg802154_rdev_list, list) {
 		if (net_eq(wpan_phy_net(&rdev->wpan_phy), net))
 			WARN_ON(cfg802154_switch_netns(rdev, &init_net));
 	}
+	mutex_unlock(&fallback_nd_lock.mutex);
 	rtnl_unlock();
 }
 
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index a512f2a647e8..e8f21de679b7 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -2855,6 +2855,7 @@  static const struct genl_ops nl802154_ops[] = {
 		.doit = nl802154_wpan_phy_netns,
 		.flags = GENL_ADMIN_PERM,
 		.internal_flags = NL802154_FLAG_NEED_WPAN_PHY |
+				  NL802154_FLAG_NEED_FALLBACK_ND_LOCK |
 				  NL802154_FLAG_NEED_RTNL,
 	},
 	{