From: Steffen Klassert <steffen.klassert@secunet.com>
To: Sanghyun Park <sanghyun.park.cnu@gmail.com>
Cc: <fw@strlen.de>, <herbert@gondor.apana.org.au>,
<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] xfrm: policy: fix use-after-free on inexact bin in xfrm_policy_bysel_ctx()
Date: Fri, 5 Jun 2026 13:01:18 +0200 [thread overview]
Message-ID: <aiKsfiLFPGBFJECs@secunet.com> (raw)
In-Reply-To: <20260602094908.2194262-1-sanghyun.park.cnu@gmail.com>
On Tue, Jun 02, 2026 at 06:49:05PM +0900, Sanghyun Park wrote:
> Fix the race by pruning the bin while still holding xfrm_policy_lock,
> before dropping it. Use __xfrm_policy_inexact_prune_bin() directly since
> the lock is already held. The wrapper xfrm_policy_inexact_prune_bin()
> becomes unused and is removed.
>
> Race:
>
> CPU0 (XFRM_MSG_DELPOLICY) CPU1 (XFRM_MSG_NEWSPDINFO)
> ========================== ==========================
> xfrm_policy_bysel_ctx():
> spin_lock_bh(xfrm_policy_lock)
> bin = xfrm_policy_inexact_lookup()
> __xfrm_policy_unlink(pol)
> spin_unlock_bh(xfrm_policy_lock)
> xfrm_policy_kill(ret)
> // wide window, lock not held
> xfrm_hash_rebuild():
> spin_lock_bh(xfrm_policy_lock)
> __xfrm_policy_inexact_flush():
> kfree_rcu(bin) // bin freed
> spin_unlock_bh(xfrm_policy_lock)
> xfrm_policy_inexact_prune_bin(bin)
> // UAF: bin is freed
>
> Fixes: 6be3b0db6db8 ("xfrm: policy: add inexact policy search tree infrastructure")
> Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com>
Applied, thanks a lot!
prev parent reply other threads:[~2026-06-05 11:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 9:49 [PATCH v2] xfrm: policy: fix use-after-free on inexact bin in xfrm_policy_bysel_ctx() Sanghyun Park
2026-06-05 11:01 ` 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=aiKsfiLFPGBFJECs@secunet.com \
--to=steffen.klassert@secunet.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sanghyun.park.cnu@gmail.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.