From: Steffen Klassert <steffen.klassert@secunet.com>
To: Michal Kosiorek <mkosiorek121@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Greg KH <gregkh@linuxfoundation.org>, <sd@queasysnail.net>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] xfrm: protect __xfrm_state_delete against double-unhash of byseq/byspi
Date: Wed, 29 Apr 2026 10:42:02 +0200 [thread overview]
Message-ID: <afHEWqYEiA07An7W@secunet.com> (raw)
In-Reply-To: <CAFRy_HgkpfzxtJEJWRa=wfJ+m_++FbGsaezywRXQWt7uhkKoTQ@mail.gmail.com>
On Wed, Apr 29, 2026 at 10:29:10AM +0200, Michal Kosiorek wrote:
...
>
> Fixes: fe9f1d8779cb ("xfrm: add state hashtable keyed by seq")
> Fixes: 7b4dc3600e48 ("[XFRM]: Do not add a state whose SPI is zero to
> the SPI hash.")
> Reported-by: Michal Kosiorek <mkosiorek121@gmail.com>
> Tested-by: Michal Kosiorek <mkosiorek121@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Michal Kosiorek <mkosiorek121@gmail.com>
> ---
> net/xfrm/xfrm_state.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 1748d374abca..686014d39429 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -818,17 +818,17 @@ int __xfrm_state_delete(struct xfrm_state *x)
>
> spin_lock(&net->xfrm.xfrm_state_lock);
> list_del(&x->km.all);
> - hlist_del_rcu(&x->bydst);
> - hlist_del_rcu(&x->bysrc);
> - if (x->km.seq)
> - hlist_del_rcu(&x->byseq);
> + hlist_del_init_rcu(&x->bydst);
> + hlist_del_init_rcu(&x->bysrc);
> + if (!hlist_unhashed(&x->byseq))
> + hlist_del_init_rcu(&x->byseq);
> if (!hlist_unhashed(&x->state_cache))
> hlist_del_rcu(&x->state_cache);
> if (!hlist_unhashed(&x->state_cache_input))
> hlist_del_rcu(&x->state_cache_input);
>
> - if (x->id.spi)
> - hlist_del_rcu(&x->byspi);
> + if (!hlist_unhashed(&x->byspi))
> + hlist_del_init_rcu(&x->byspi);
> net->xfrm.state_num--;
> xfrm_nat_keepalive_state_updated(x);
> spin_unlock(&net->xfrm.xfrm_state_lock);
This looks still odd, the indentation seems to be wrong.
It does not apply, maybe your mail client malformed
the patch.
next prev parent reply other threads:[~2026-04-29 8:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAFRy_Hg8O9smcwzWTdBn6j6NLwv+8vBXKtm2KTsOoG1CjxC2Dg@mail.gmail.com>
[not found] ` <afGug2nzdfjEGHxO@secunet.com>
2026-04-29 8:29 ` [PATCH] xfrm: protect __xfrm_state_delete against double-unhash of byseq/byspi Michal Kosiorek
2026-04-29 8:42 ` Steffen Klassert [this message]
2026-04-29 8:54 ` [PATCH ipsec v2] xfrm: defensively unhash xfrm_state lists in __xfrm_state_delete Michal Kosiorek
2026-04-30 7:57 ` Steffen Klassert
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=afHEWqYEiA07An7W@secunet.com \
--to=steffen.klassert@secunet.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkosiorek121@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
/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.