linux/drivers/net/wireguard
Shardul Bankar 60a25ef8da wireguard: device: use exit_rtnl callback instead of manual rtnl_lock in pre_exit
wg_netns_pre_exit() manually acquires rtnl_lock() inside the
pernet .pre_exit callback.  This causes a hung task when another
thread holds rtnl_mutex - the cleanup_net workqueue (or the
setup_net failure rollback path) blocks indefinitely in
wg_netns_pre_exit() waiting to acquire the lock.

Convert to .exit_rtnl, introduced in commit 7a60d91c69 ("net:
Add ->exit_rtnl() hook to struct pernet_operations."), where the
framework already holds RTNL and batches all callbacks under a
single rtnl_lock()/rtnl_unlock() pair, eliminating the contention
window.

The rcu_assign_pointer(wg->creating_net, NULL) is safe to move
from .pre_exit to .exit_rtnl (which runs after synchronize_rcu())
because all RCU readers of creating_net either use maybe_get_net()
- which returns NULL for a dying namespace with zero refcount - or
access net->user_ns which remains valid throughout the entire
ops_undo_list sequence.

Reported-by: syzbot+f2fbf7478a35a94c8b7c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=cb64c22a492202ca929e18262fdb8cb89e635c70
Signed-off-by: Shardul Bankar <shardul.b@mpiricsoftware.com>
[ Jason: added __net_exit and __read_mostly annotations that were missing. ]
Fixes: 900575aa33 ("wireguard: device: avoid circular netns references")
Cc: stable@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Link: https://patch.msgid.link/20260414153944.2742252-5-Jason@zx2c4.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-04-14 11:48:04 -07:00
..
generated wireguard: netlink: generate netlink code 2025-12-02 04:12:49 +01:00
selftest wireguard: allowedips: remove redundant space 2026-04-14 11:48:04 -07:00
allowedips.c wireguard: allowedips: Use kfree_rcu() instead of call_rcu() 2026-04-14 11:48:04 -07:00
allowedips.h wireguard: allowedips: add WGALLOWEDIP_F_REMOVE_ME flag 2025-05-27 09:06:19 +02:00
cookie.c lib/crypto: blake2s: Rename blake2s_state to blake2s_ctx 2025-10-29 22:04:24 -07:00
cookie.h
device.c wireguard: device: use exit_rtnl callback instead of manual rtnl_lock in pre_exit 2026-04-14 11:48:04 -07:00
device.h wireguard: receive: use ring buffer for incoming handshakes 2021-11-29 19:50:50 -08:00
main.c genetlink: remove linux/genetlink.h 2024-04-01 21:44:34 -07:00
Makefile wireguard: netlink: generate netlink code 2025-12-02 04:12:49 +01:00
messages.h
netlink.c wireguard: netlink: generate netlink code 2025-12-02 04:12:49 +01:00
netlink.h
noise.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
noise.h
peer.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
peer.h wireguard: peer: Replace sockaddr with sockaddr_inet 2025-07-25 15:29:58 -07:00
peerlookup.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
peerlookup.h
queueing.c wireguard: queueing: use saner cpu selection wrapping 2023-07-03 09:17:52 +01:00
queueing.h wireguard: queueing: always return valid online CPU in wg_cpumask_choose_online() 2025-09-11 18:52:21 -07:00
ratelimiter.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ratelimiter.h
receive.c wireguard: receive: annotate data-race around receiving_counter.counter 2024-03-19 11:22:49 +01:00
send.c wireguard: send: annotate intentional data race in checking empty queue 2024-07-05 17:21:10 -07:00
socket.c drivers: net: drop ipv6_stub usage and use direct function calls 2026-03-29 11:21:23 -07:00
socket.h
timers.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
timers.h
version.h