Commit 4b2eca2
net: core: fix lockdep splat on device unregister
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
kernel-patches#1: ..d40 (net_cleanup_work){+.+.}-{0:0}, at: process_one_work
kernel-patches#2: ..bd0 (pernet_ops_rwsem){++++}-{4:4}, at: cleanup_net
kernel-patches#3: ..aa8 (rtnl_mutex){+.+.}-{4:4}, at: default_device_exit_batch
kernel-patches#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]>
Signed-off-by: NipaLocal <nipa@local>1 parent 82dc4f0 commit 4b2eca2
1 file changed
+35
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12211 | 12211 | | |
12212 | 12212 | | |
12213 | 12213 | | |
| 12214 | + | |
| 12215 | + | |
| 12216 | + | |
| 12217 | + | |
| 12218 | + | |
| 12219 | + | |
| 12220 | + | |
| 12221 | + | |
| 12222 | + | |
| 12223 | + | |
| 12224 | + | |
| 12225 | + | |
| 12226 | + | |
| 12227 | + | |
| 12228 | + | |
| 12229 | + | |
| 12230 | + | |
| 12231 | + | |
| 12232 | + | |
| 12233 | + | |
| 12234 | + | |
| 12235 | + | |
| 12236 | + | |
| 12237 | + | |
| 12238 | + | |
| 12239 | + | |
| 12240 | + | |
| 12241 | + | |
| 12242 | + | |
12214 | 12243 | | |
12215 | 12244 | | |
12216 | 12245 | | |
| |||
12243 | 12272 | | |
12244 | 12273 | | |
12245 | 12274 | | |
| 12275 | + | |
| 12276 | + | |
12246 | 12277 | | |
12247 | 12278 | | |
12248 | 12279 | | |
12249 | 12280 | | |
| 12281 | + | |
12250 | 12282 | | |
12251 | | - | |
12252 | | - | |
| 12283 | + | |
| 12284 | + | |
12253 | 12285 | | |
12254 | | - | |
12255 | | - | |
12256 | | - | |
| 12286 | + | |
12257 | 12287 | | |
12258 | 12288 | | |
12259 | 12289 | | |
| |||
0 commit comments