From: Steffen Klassert <steffen.klassert@secunet.com>
To: Hyunwoo Kim <imv4bel@gmail.com>
Cc: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<horms@kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH net] xfrm: Fix work re-schedule after cancel in xfrm_nat_keepalive_net_fini()
Date: Mon, 16 Mar 2026 10:57:45 +0100 [thread overview]
Message-ID: <abfUGf-GvWLfGqjG@secunet.com> (raw)
In-Reply-To: <abBf_R81PYmafhWv@v4bel>
On Wed, Mar 11, 2026 at 03:16:29AM +0900, Hyunwoo Kim wrote:
> After cancel_delayed_work_sync() is called from
> xfrm_nat_keepalive_net_fini(), xfrm_state_fini() flushes remaining
> states via __xfrm_state_delete(), which calls
> xfrm_nat_keepalive_state_updated() to re-schedule nat_keepalive_work.
>
> The following is a simple race scenario:
>
> cpu0 cpu1
>
> cleanup_net() [Round 1]
> ops_undo_list()
> xfrm_net_exit()
> xfrm_nat_keepalive_net_fini()
> cancel_delayed_work_sync(nat_keepalive_work);
> xfrm_state_fini()
> xfrm_state_flush()
> xfrm_state_delete(x)
> __xfrm_state_delete(x)
> xfrm_nat_keepalive_state_updated(x)
> schedule_delayed_work(nat_keepalive_work);
> rcu_barrier();
> net_complete_free();
> net_passive_dec(net);
> llist_add(&net->defer_free_list, &defer_free_list);
>
> cleanup_net() [Round 2]
> rcu_barrier();
> net_complete_free()
> kmem_cache_free(net_cachep, net);
> nat_keepalive_work()
> // on freed net
>
> To prevent this, cancel_delayed_work_sync() is replaced with
> disable_delayed_work_sync().
>
> Fixes: f531d13bdfe3 ("xfrm: support sending NAT keepalives in ESP in UDP states")
> Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Applied, thanks a lot!
prev parent reply other threads:[~2026-03-16 9:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 18:16 [PATCH net] xfrm: Fix work re-schedule after cancel in xfrm_nat_keepalive_net_fini() Hyunwoo Kim
2026-03-10 22:57 ` Sabrina Dubroca
2026-03-11 0:14 ` Eyal Birger
2026-03-11 9:26 ` Sabrina Dubroca
2026-03-11 10:31 ` Hyunwoo Kim
2026-03-11 13:00 ` Eyal Birger
2026-03-11 13:27 ` Sabrina Dubroca
2026-03-11 13:40 ` Hyunwoo Kim
2026-03-16 9:57 ` Steffen Klassert [this message]
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=abfUGf-GvWLfGqjG@secunet.com \
--to=steffen.klassert@secunet.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=imv4bel@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.