Commit 00d8c45
net: core: fix lockdep splat on device unregister
[ Upstream commit 7f0fddd ]
Since blamed commit, unregister_netdevice_many_notify() takes the netdev
mutex if the device needs it.
If the device list is too long, this will lock more device mutexes than
lockdep can handle:
unshare -n \
bash -c 'for i in $(seq 1 100);do ip link add foo$i type dummy;done'
BUG: MAX_LOCK_DEPTH too low!
turning off the locking correctness validator.
depth: 48 max: 48!
48 locks held by kworker/u16:1/69:
#0: ..148 ((wq_completion)netns){+.+.}-{0:0}, at: process_one_work
#1: ..d40 (net_cleanup_work){+.+.}-{0:0}, at: process_one_work
#2: ..bd0 (pernet_ops_rwsem){++++}-{4:4}, at: cleanup_net
#3: ..aa8 (rtnl_mutex){+.+.}-{4:4}, at: default_device_exit_batch
#4: ..cb0 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: unregister_netdevice_many_notify
[..]
Add a helper to close and then unlock a list of net_devices.
Devices that are not up have to be skipped - netif_close_many always
removes them from the list without any other actions taken, so they'd
remain in locked state.
Close devices whenever we've used up half of the tracking slots or we
processed entire list without hitting the limit.
Fixes: 7e4d784 ("net: hold netdev instance lock during rtnetlink operations")
Signed-off-by: Florian Westphal <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>1 parent be643d3 commit 00d8c45
1 file changed
+35
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12088 | 12088 | | |
12089 | 12089 | | |
12090 | 12090 | | |
| 12091 | + | |
| 12092 | + | |
| 12093 | + | |
| 12094 | + | |
| 12095 | + | |
| 12096 | + | |
| 12097 | + | |
| 12098 | + | |
| 12099 | + | |
| 12100 | + | |
| 12101 | + | |
| 12102 | + | |
| 12103 | + | |
| 12104 | + | |
| 12105 | + | |
| 12106 | + | |
| 12107 | + | |
| 12108 | + | |
| 12109 | + | |
| 12110 | + | |
| 12111 | + | |
| 12112 | + | |
| 12113 | + | |
| 12114 | + | |
| 12115 | + | |
| 12116 | + | |
| 12117 | + | |
| 12118 | + | |
| 12119 | + | |
12091 | 12120 | | |
12092 | 12121 | | |
12093 | 12122 | | |
| |||
12120 | 12149 | | |
12121 | 12150 | | |
12122 | 12151 | | |
| 12152 | + | |
| 12153 | + | |
12123 | 12154 | | |
12124 | 12155 | | |
12125 | 12156 | | |
12126 | 12157 | | |
| 12158 | + | |
12127 | 12159 | | |
12128 | | - | |
12129 | | - | |
| 12160 | + | |
| 12161 | + | |
12130 | 12162 | | |
12131 | | - | |
12132 | | - | |
12133 | | - | |
| 12163 | + | |
12134 | 12164 | | |
12135 | 12165 | | |
12136 | 12166 | | |
| |||
0 commit comments