net: Hold __rtnl_net_lock() in (un)?register_netdevice_notifier().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Mon, 6 Jan 2025 07:07:49 +0000 (16:07 +0900)
committerJakub Kicinski <kuba@kernel.org>
Wed, 8 Jan 2025 01:49:19 +0000 (17:49 -0800)
commita239e0625097bccdd4065390952fe9e6d0fdf02b
treec837fe82812876a2931999f753435b20cfe80977
parent4ce1aeece911c7fe3ac6afb96dbc2c6ef20da639
net: Hold __rtnl_net_lock() in (un)?register_netdevice_notifier().

(un)?register_netdevice_notifier() hold pernet_ops_rwsem and RTNL,
iterate all netns, and trigger the notifier for all netdev.

Let's hold __rtnl_net_lock() before triggering the notifier.

Note that we will need protection for netdev_chain when RTNL is
removed.  (e.g. blocking_notifier conversion [0] with a lockdep
annotation [1])

Link: https://lore.kernel.org/netdev/20250104063735.36945-2-kuniyu@amazon.com/
Link: https://lore.kernel.org/netdev/20250105075957.67334-1-kuniyu@amazon.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250106070751.63146-2-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.c