linux/net
Florian Westphal 7f0fddd817 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
 #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: 7e4d784f58 ("net: hold netdev instance lock during rtnetlink operations")
Signed-off-by: Florian Westphal <fw@strlen.de>
Link: https://patch.msgid.link/20251013185052.14021-1-fw@strlen.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-10-14 19:27:20 -07:00
..
6lowpan
9p
802
8021q
appletalk
atm net: atm: fix memory leak in atm_register_sysfs when device_register fail 2025-09-04 09:53:44 +02:00
ax25 ax25: properly unshare skbs in ax25_kiss_rcv() 2025-09-03 17:06:30 -07:00
batman-adv batman-adv: remove includes for extern declarations 2025-09-05 15:11:02 +02:00
bluetooth Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings 2025-09-27 11:37:43 -04:00
bpf Merge branch 'bpf-next/xdp_pull_data' into 'bpf-next/master' 2025-09-23 16:23:58 -07:00
bridge bridge: br_vlan_fill_forward_path_pvid: use br_vlan_group_rcu() 2025-10-08 13:17:31 +02:00
caif caif: Replace memset(0) + strscpy() with strscpy_pad() 2025-08-12 14:08:56 -07:00
can can: annotate mtu accesses with READ_ONCE() 2025-09-23 10:04:58 +02:00
ceph net: WQ_PERCPU added to alloc_workqueue users 2025-09-22 17:40:30 -07:00
core net: core: fix lockdep splat on device unregister 2025-10-14 19:27:20 -07:00
dcb Revert "Documentation: net: add flow control guide and document ethtool API" 2025-10-01 09:48:21 +02:00
devlink net: replace use of system_wq with system_percpu_wq 2025-09-22 17:40:30 -07:00
dns_resolver
dsa
ethernet ethernet: Extend device_get_mac_address() to use NVMEM 2025-09-15 18:34:08 -07:00
ethtool Revert "Documentation: net: add flow control guide and document ethtool API" 2025-10-01 09:48:21 +02:00
handshake
hsr Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-09-11 17:40:13 -07:00
ieee802154
ife
ipv4 tcp: fix tcp_tso_should_defer() vs large RTT 2025-10-14 12:21:48 +02:00
ipv6 net/ip6_tunnel: Prevent perpetual tunnel growth 2025-10-13 17:43:46 -07:00
iucv net: add sk_drops_read(), sk_drops_inc() and sk_drops_reset() helpers 2025-08-28 13:14:50 +02:00
kcm net: kcm: Fix race condition in kcm_unattach() 2025-08-13 18:18:33 -07:00
key
l2tp l2tp: do not use sock_hold() in pppol2tp_session_get_sock() 2025-08-27 17:16:13 -07:00
l3mdev
lapb
llc
mac80211 wifi: mac80211: fix Rx packet handling when pubsta information is not available 2025-09-19 11:59:34 +02:00
mac802154
mctp net: mctp: fix typo in comment 2025-09-08 17:47:57 -07:00
mpls
mptcp mptcp: minor move_skbs_to_msk() cleanup 2025-09-29 18:23:36 -07:00
ncsi
netfilter netfilter: nft_objref: validate objref and objrefmap expressions 2025-10-08 13:17:25 +02:00
netlabel audit: add record for multiple task security contexts 2025-08-30 10:15:30 -04:00
netlink Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-09-11 17:40:13 -07:00
netrom
nfc net: nfc: nci: Add parameter validation for packet data 2025-09-30 10:27:14 +02:00
nsh
openvswitch net: replace use of system_wq with system_percpu_wq 2025-09-22 17:40:30 -07:00
packet net: af_packet: Use hrtimer to do the retire operation 2025-09-11 18:40:06 -07:00
phonet net: add sk_drops_read(), sk_drops_inc() and sk_drops_reset() helpers 2025-08-28 13:14:50 +02:00
psample
psp net: psp: don't assume reply skbs will have a socket 2025-10-03 10:23:50 -07:00
qrtr
rds net: WQ_PERCPU added to alloc_workqueue users 2025-09-22 17:40:30 -07:00
rfkill net: replace use of system_wq with system_percpu_wq 2025-09-22 17:40:30 -07:00
rose net: rose: fix a typo in rose_clear_routes() 2025-08-27 17:27:52 -07:00
rxrpc net: WQ_PERCPU added to alloc_workqueue users 2025-09-22 17:40:30 -07:00
sched net_sched: act: remove tcfa_qstats 2025-09-02 15:52:24 -07:00
sctp net/sctp: fix a null dereference in sctp_disposition sctp_sf_do_5_1D_ce() 2025-10-06 11:07:20 -07:00
shaper
smc dibs: Move event handling to dibs layer 2025-09-23 11:13:22 +02:00
strparser
sunrpc NFSD 6.18 Release Notes 2025-10-06 13:22:21 -07:00
switchdev
tipc net: doc: Fix typos in docs 2025-10-03 10:24:14 -07:00
tls tls: Avoid -Wflex-array-member-not-at-end warning 2025-09-24 16:23:02 -07:00
unix Networking changes for 6.18. 2025-10-02 15:17:01 -07:00
vmw_vsock hyperv-next for v6.18 2025-10-07 08:40:15 -07:00
wireless wifi: cfg80211: fix width unit in cfg80211_radio_chandef_valid() 2025-09-23 09:50:02 +02:00
x25
xdp xsk: wrap generic metadata handling onto separate function 2025-09-26 13:51:45 -07:00
xfrm ipsec-next-2025-09-26 2025-09-26 14:44:50 -07:00
Kconfig dibs: Create drivers/dibs 2025-09-23 11:13:21 +02:00
Kconfig.debug
Makefile psp: base PSP device support 2025-09-18 12:32:06 +02:00
compat.c
devres.c
socket.c Networking changes for 6.18. 2025-10-02 15:17:01 -07:00
sysctl_net.c