Re: [devel-ipsec] Re: [PATCH ipsec-next v5 1/8] xfrm: add missing __rcu annotation to nlsk
From: Antony Antony
Date: Thu Mar 05 2026 - 02:47:06 EST
On Thu, Feb 26, 2026 at 06:07:41PM +0100, Sabrina Dubroca via Devel wrote:
> 2026-01-27, 11:42:01 +0100, Antony Antony wrote:
> > The nlsk field in struct netns_xfrm is RCU-protected, as seen by
> > the use of rcu_assign_pointer() and RCU_INIT_POINTER() when updating
> > it.
> > However, the field lacks the __rcu annotation, and most read-side
> > accesses don't use rcu_dereference().
> >
> > Add the missing __rcu annotation and convert all read-side accesses to
> > use rcu_dereference() for correctness and to silence sparse warnings.
> >
> > Sparse warning reported by NIPA allmodconfig test when modifying
> > net/xfrm/xfrm_user.c. The warning is a pre-existing issue in
> > xfrm_nlmsg_multicast(). This series added a new call to this function
> > and NIPA testing reported a new warning was added by this series.
> >
> > To reproduce (requires sparse):
> > make C=2 net/xfrm/
> > net/xfrm/xfrm_user.c:1574:29: error: incompatible types in comparison
> > expression (different address spaces):
> > net/xfrm/xfrm_user.c:1574:29: struct sock [noderef] __rcu *
> > net/xfrm/xfrm_user.c:1574:29: struct sock *
>
> BTW, after this, sparse will complain about the other accesses to nlsk
> in net/xfrm/xfrm_user.c (in the nlmsg_unicast(net->xfrm.nlsk, ...)
> calls).
Indeed there are more sparse warning. I am glad to hear you working on a
borader patch!
I stayed focused on this one since it was directly triggered by my patch
series, and I couldn't find much guidance on the others easily.
>
> I have a patch adding this __rcu annotation, and fixing the warnings
> that it causes. It's part of the series I'm planning to submit very
> soon, which fixes a lot of rcu-related warnings in net/xfrm/*.
I am looking forward to this. I'll keep my patch for now as a fix. If your
series lands first, I'm happy to drop mine.
-antony