default_device_exit_net() could call dev_change_net_namespace() to move devices from a dying netns to init_net. Let's hold the two netns __rtnl_net_lock() around it. Signed-off-by: Kuniyuki Iwashima --- net/core/dev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 4b3d5cfdf6e0..c477c4f84ed9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -13034,7 +13034,7 @@ static void __net_exit default_device_exit_net(struct net *net) * Push all migratable network devices back to the * initial network namespace */ - ASSERT_RTNL(); + for_each_netdev_safe(net, dev, aux) { int err; char fb_name[IFNAMSIZ]; @@ -13077,11 +13077,19 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list) LIST_HEAD(dev_kill_list); rtnl_lock(); + + __rtnl_net_lock(&init_net); + list_for_each_entry(net, net_list, exit_list) { + __rtnl_net_lock(net); default_device_exit_net(net); + __rtnl_net_unlock(net); + cond_resched(); } + __rtnl_net_unlock(&init_net); + list_for_each_entry(net, net_list, exit_list) { for_each_netdev_reverse(net, dev) { if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) -- 2.55.0.rc0.799.gd6f94ed593-goog