rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
Subsystems (2)
PATCH v2 1/1 rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
rtnl_net_debug_init() registers rtnl_net_debug_net_ops by register_pernet_device() but calls unregister_pernet_subsys() in case register_netdevice_notifier() fails.
It corrupts pernet_list because first_device is updated in register_pernet_device() but not unregister_pernet_subsys().
Let's fix it by calling register_pernet_subsys() instead.
The _subsys() one fits better for the use case because it keeps the notifier alive until default_device_exit_net(), giving it more chance to test NETDEV_UNREGISTER.
---
v2: Correct changelog
v1: https://lore.kernel.org/netdev/[email protected]/
--- net/core/rtnl_net_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/rtnl_net_debug.c +1 -1
@@ -102,7 +102,7 @@ static int __init rtnl_net_debug_init(void) {int ret; - ret =register_pernet_device (&rtnl_net_debug_net_ops); + ret =register_pernet_subsys (&rtnl_net_debug_net_ops);if (ret)return ret;
Signature · 1 line
2.48.1
Quoted 13 lines · Kuniyuki Iwashima
rtnl_net_debug_init()registersrtnl_net_debug_net_opsbyregister_pernet_device()but callsunregister_pernet_subsys()in caseregister_netdevice_notifier()fails.It corrupts
pernet_listbecausefirst_deviceis updated inregister_pernet_device()but notunregister_pernet_subsys().Let's fix it by calling
register_pernet_subsys()instead.The
_subsys()one fits better for the use case because it keeps the notifier alive untildefault_device_exit_net(), giving it more chance to testNETDEV_UNREGISTER.
Quoted 5 lines
Fixes 03fa53485659 ("rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier.")Signed-off-by Kuniyuki Iwashima <[email protected]>---
v2: Correct changelog
v1: https://lore.kernel.org/netdev/[email protected]/
Thanks for the update.
...
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 1 Apr 2025 12:07:08 -0700 you wrote:
rtnl_net_debug_init()registersrtnl_net_debug_net_opsbyregister_pernet_device()but callsunregister_pernet_subsys()in caseregister_netdevice_notifier()fails.It corrupts
pernet_listbecausefirst_deviceis updated inregister_pernet_device()but notunregister_pernet_subsys().[...]
Here is the summary with links:
- [v2,net] rtnetlink: Use register_pernet_subsys() in rtnl_net_debug_init().
https://git.kernel.org/netdev/net/c/1b7fdc702c03
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html