From: Florian Westphal <fw@strlen.de>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH ipsec 2/2] xfrm: Wait for RCU readers during state netns exit
Date: Thu, 2 Apr 2026 13:57:37 +0200 [thread overview]
Message-ID: <ac5ZsQTyo16xST_a@strlen.de> (raw)
In-Reply-To: <ac5TqJaXXg66dqBy@secunet.com>
Steffen Klassert <steffen.klassert@secunet.com> wrote:
> xfrm_state_fini() flushes the resize and GC work, destroys all states, and
> then frees the state hash tables and the inbound percpu state cache.
> Those objects can still be observed by concurrent RCU readers. We need
> to wait for a RCU grace period before freeing the hash tables and the
> percpu cache to avoid netns teardown racing with lockless lookups.
>
> Fix this by adding synchronize_rcu() before freeing the state hash
> tables and the inbound percpu state cache.
>
> Fixes: c8406998b801 ("xfrm: state: use rcu_deref and assign_pointer helpers")
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> ---
> net/xfrm/xfrm_state.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 1748d374abca..84fbf1591138 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -3327,6 +3327,8 @@ void xfrm_state_fini(struct net *net)
> xfrm_state_flush(net, 0, false);
> flush_work(&xfrm_state_gc_work);
>
> + synchronize_rcu();
> +
xfrm_state_flush() is expected to relink all states to the gc list for
the gc worker to handle.
The xfrm state worker calls synchronize_rcu() and then frees states
on the state gc list.
What scenario does this additional synchronize_rcu() protect against?
AFAICS this one is not needed, but maybe i am missing something?
next prev parent reply other threads:[~2026-04-02 11:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 11:31 [PATCH ipsec 1/2] xfrm: Wait for RCU readers during policy netns exit Steffen Klassert
2026-04-02 11:31 ` [PATCH ipsec 2/2] xfrm: Wait for RCU readers during state " Steffen Klassert
2026-04-02 11:57 ` Florian Westphal [this message]
2026-04-02 12:06 ` Steffen Klassert
2026-04-02 11:52 ` [PATCH ipsec 1/2] xfrm: Wait for RCU readers during policy " Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ac5ZsQTyo16xST_a@strlen.de \
--to=fw@strlen.de \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox