]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xfrm: avoid RCU warnings around the per-netns netlink socket
authorSabrina Dubroca <sd@queasysnail.net>
Mon, 9 Mar 2026 10:32:43 +0000 (11:32 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 12 Mar 2026 06:16:02 +0000 (07:16 +0100)
commitd87f8bc47fbf012a7f115e311d0603d97e47c34c
tree01835b29c26fd103afa0259a0b8982aceabd1951
parent103b4f5b4007cb484f40b1c8095a7e0526e5aff6
xfrm: avoid RCU warnings around the per-netns netlink socket

net->xfrm.nlsk is used in 2 types of contexts:
 - fully under RCU, with rcu_read_lock + rcu_dereference and a NULL check
 - in the netlink handlers, with requests coming from a userspace socket

In the 2nd case, net->xfrm.nlsk is guaranteed to stay non-NULL and the
object is alive, since we can't enter the netns destruction path while
the user socket holds a reference on the netns.

After adding the __rcu annotation to netns_xfrm.nlsk (which silences
sparse warnings in the RCU users and __net_init code), we need to tell
sparse that the 2nd case is safe. Add a helper for that.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/netns/xfrm.h
net/xfrm/xfrm_user.c