WSL2-Linux-Kernel/net/core
Johannes Berg 0b5c21bbc0 net: ensure net_todo_list is processed quickly
In [1], Will raised a potential issue that the cfg80211 code,
which does (from a locking perspective)

  rtnl_lock()
  wiphy_lock()
  rtnl_unlock()

might be suspectible to ABBA deadlocks, because rtnl_unlock()
calls netdev_run_todo(), which might end up calling rtnl_lock()
again, which could then deadlock (see the comment in the code
added here for the scenario).

Some back and forth and thinking ensued, but clearly this can't
happen if the net_todo_list is empty at the rtnl_unlock() here.
Clearly, the code here cannot actually put an entry on it, and
all other users of rtnl_unlock() will empty it since that will
always go through netdev_run_todo(), emptying the list.

So the only other way to get there would be to add to the list
and then unlock the RTNL without going through rtnl_unlock(),
which is only possible through __rtnl_unlock(). However, this
isn't exported and not used in many places, and none of them
seem to be able to unregister before using it.

Therefore, add a WARN_ON() in the code to ensure this invariant
won't be broken, so that the cfg80211 (or any similar) code
stays safe.

[1] https://lore.kernel.org/r/Yjzpo3TfZxtKPMAG@google.com

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/20220404113847.0ee02e4a70da.Ic73d206e217db20fd22dcec14fe5442ca732804b@changeid
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-04-05 14:28:16 -07:00
..
Makefile
bpf_sk_storage.c bpf: Check for NULL return from bpf_get_btf_vmlinux 2022-03-20 19:21:38 -07:00
datagram.c
datagram.h
dev.c net: ensure net_todo_list is processed quickly 2022-04-05 14:28:16 -07:00
dev_addr_lists.c
dev_addr_lists_test.c
dev_ioctl.c
devlink.c devlink: hold the instance lock during eswitch_mode callbacks 2022-03-21 14:11:38 +00:00
drop_monitor.c
dst.c
dst_cache.c
failover.c
fib_notifier.c
fib_rules.c
filter.c bpf: Treat bpf_sk_lookup remote_port as a 2-byte field 2022-03-20 18:58:59 -07:00
flow_dissector.c flow_dissector: Add support for HSRv0 2022-03-11 11:05:52 +00:00
flow_offload.c
gen_estimator.c
gen_stats.c
gro.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-03-10 17:16:56 -08:00
gro_cells.c net: add per-cpu storage and net->core_stats 2022-03-11 23:17:24 -08:00
hwbm.c
link_watch.c
lwt_bpf.c
lwtunnel.c
neighbour.c
net-procfs.c
net-sysfs.c Linux 5.17-rc8 2022-03-15 10:28:12 +01:00
net-sysfs.h
net-traces.c
net_namespace.c
netclassid_cgroup.c
netevent.c
netpoll.c
netprio_cgroup.c
of_net.c
page_pool.c page_pool: Add function to batch and return stats 2022-03-03 09:55:28 +00:00
pktgen.c
ptp_classifier.c ptp: Add generic PTP is_sync() function 2022-03-07 11:31:34 +00:00
request_sock.c
rtnetlink.c net: ensure net_todo_list is processed quickly 2022-04-05 14:28:16 -07:00
scm.c
secure_seq.c
selftests.c
skbuff.c net: skb: introduce the function kfree_skb_list_reason() 2022-03-04 12:17:11 +00:00
skmsg.c bpf, sockmap: Fix memleak in tcp_bpf_sendmsg while sk msg is full 2022-03-15 16:43:31 +01:00
sock.c SO_ZEROCOPY should return -EOPNOTSUPP rather than -ENOTSUPP 2022-03-08 22:14:49 -08:00
sock_destructor.h
sock_diag.c
sock_map.c
sock_reuseport.c
stream.c
sysctl_net_core.c net/sysctl: avoid two synchronize_rcu() calls 2022-02-28 11:40:47 +00:00
timestamping.c
tso.c
utils.c
xdp.c Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2022-03-22 11:18:49 -07:00