]> git.baikalelectronics.ru Git - kernel.git/commit
net: Do not take net_rwsem in __rtnl_link_unregister()
authorKirill Tkhai <ktkhai@virtuozzo.com>
Fri, 30 Mar 2018 16:38:37 +0000 (19:38 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2018 02:24:58 +0000 (22:24 -0400)
commit95a5a8db2653f61f12ec73a20e730a24aa94fdef
treebc6dd02f1ba8878c6fd3ecb8ce86e1f0d6fdb4c9
parent5ddcec51d613cf9a32f8641d22dd07050dc16c10
net: Do not take net_rwsem in __rtnl_link_unregister()

This function calls call_netdevice_notifier(), which also
may take net_rwsem. So, we can't use net_rwsem here.

This patch makes callers of this functions take pernet_ops_rwsem,
like register_netdevice_notifier() does. This will protect
the modifications of net_namespace_list, and allows notifiers
to take it (they won't have to care about context).

Since __rtnl_link_unregister() is used on module load
and unload (which are not frequent operations), this looks
for me better, than make all call_netdevice_notifier()
always executing in "protected net_namespace_list" context.

Also, this fixes the problem we had a deal in 51de843fb670
"Close race between {un, }register_netdevice_notifier and ...",
and guarantees __rtnl_link_unregister() does not skip
exitting net.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dummy.c
drivers/net/ifb.c
net/core/net_namespace.c
net/core/rtnetlink.c