From: Simon Horman <horms@kernel.org>
To: Zhenghang Xiao <kipreyyy@gmail.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH xfrm] xfrm: iptfs: fix use-after-free on first_skb in __input_process_payload
Date: Mon, 1 Jun 2026 17:50:21 +0100 [thread overview]
Message-ID: <20260601165021.GZ2256768@horms.kernel.org> (raw)
In-Reply-To: <20260526105328.87078-1-kipreyyy@gmail.com>
On Tue, May 26, 2026 at 06:53:28PM +0800, Zhenghang Xiao wrote:
> __input_process_payload() stores first_skb into xtfs->ra_newskb under
> drop_lock when starting partial reassembly, then unlocks and breaks out
> of the processing loop. The post-loop check reads xtfs->ra_newskb
> without the lock to decide whether first_skb is still owned:
>
> if (first_skb && first_iplen && !defer && first_skb != xtfs->ra_newskb)
>
> Between spin_unlock and this read, a concurrent CPU running
> iptfs_reassem_cont() (or the drop_timer hrtimer) can complete
> reassembly, NULL xtfs->ra_newskb, and free the skb. The check then
> evaluates first_skb != NULL as true, and pskb_trim/ip_summed/consume_skb
> operate on the freed skb — a use-after-free in skbuff_head_cache.
>
> Replace the unlocked read with a local bool that records whether
> first_skb was handed to the reassembly state in the current call. The
> flag is set after the existing spin_unlock, before the break, using the
> pointer equality that is stable at that point (first_skb == skb iff
> first_skb was stored in ra_newskb).
>
> Fixes: 3f3339885fb3 ("xfrm: iptfs: add reusing received skb for the tunnel egress packet")
> Signed-off-by: Zhenghang Xiao <kipreyyy@gmail.com>
FTR: An AI generated review of this patch is available on sashiko.dev.
I believe that review can be treated in the context of possible follow-up
and should not effect the progress of this patch.
prev parent reply other threads:[~2026-06-01 16:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 10:53 [PATCH xfrm] xfrm: iptfs: fix use-after-free on first_skb in __input_process_payload Zhenghang Xiao
2026-06-01 16:50 ` Simon Horman [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=20260601165021.GZ2256768@horms.kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kipreyyy@gmail.com \
--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