Skip to content

Commit 08e9f2d

Browse files
Cosmin Ratiukuba-moo
authored andcommitted
net: Lock netdevices during dev_shutdown
__qdisc_destroy() calls into various qdiscs .destroy() op, which in turn can call .ndo_setup_tc(), which requires the netdev instance lock. This commit extends the critical section in unregister_netdevice_many_notify() to cover dev_shutdown() (and dev_tcx_uninstall() as a side-effect) and acquires the netdev instance lock in __dev_change_net_namespace() for the other dev_shutdown() call. This should now guarantee that for all qdisc ops, the netdev instance lock is held during .ndo_setup_tc(). Fixes: a0527ee ("net: hold netdev instance lock during qdisc ndo_setup_tc") Signed-off-by: Cosmin Ratiu <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0093cb1 commit 08e9f2d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/core/dev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11966,9 +11966,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
1196611966
struct sk_buff *skb = NULL;
1196711967

1196811968
/* Shutdown queueing discipline. */
11969+
netdev_lock_ops(dev);
1196911970
dev_shutdown(dev);
1197011971
dev_tcx_uninstall(dev);
11971-
netdev_lock_ops(dev);
1197211972
dev_xdp_uninstall(dev);
1197311973
dev_memory_provider_uninstall(dev);
1197411974
netdev_unlock_ops(dev);
@@ -12161,7 +12161,9 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
1216112161
synchronize_net();
1216212162

1216312163
/* Shutdown queueing discipline. */
12164+
netdev_lock_ops(dev);
1216412165
dev_shutdown(dev);
12166+
netdev_unlock_ops(dev);
1216512167

1216612168
/* Notify protocols, that we are about to destroy
1216712169
* this device. They should clean all the things.

0 commit comments

Comments
 (0)