Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "D. Wythe" <alibuda@linux.alibaba.com>
Cc: stable@vger.kernel.org, patches@lists.linux.dev,
	zdi-disclosures@trendmicro.com,
	Sabrina Dubroca <sd@queasysnail.net>,
	Breno Leitao <leitao@debian.org>,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: Re: [PATCH 5.10 28/43] xfrm: espintcp: fix UAF during close
Date: Sat, 5 Sep 2026 13:16:02 +0200	[thread overview]
Message-ID: <2026090558-issue-factoid-6115@gregkh> (raw)
In-Reply-To: <20260905101704.GA47841@j66a10360.sqa.eu95>

On Sat, Sep 05, 2026 at 06:17:04PM +0800, D. Wythe wrote:
> On Fri, Sep 04, 2026 at 02:15:30PM +0200, Greg Kroah-Hartman wrote:
> > On Fri, Sep 04, 2026 at 05:51:58PM +0800, D. Wythe wrote:
> > > On Mon, Aug 31, 2026 at 03:35:36PM +0200, Greg Kroah-Hartman wrote:
> > > > 5.10-stable review patch.  If anyone has any objections, please let me know.
> > > > 
> > > > ------------------
> > > > 
> > > > From: Sabrina Dubroca <sd@queasysnail.net>
> > > > 
> > > > commit deb232e884877bf10b4ce2580909eedec986c284 upstream.
> > > > 
> > > > ZDI reported and analyzed a race condition during close for espintcp
> > > > sockets:
> > > > 
> > > >     espintcp_close() frees emsg->skb via kfree_skb() without holding
> > > >     any socket lock. Concurrently, the xfrm_trans_reinject work queue
> > > >     invokes esp_output_tcp_finish() -> espintcp_push_skb() ->
> > > >     espintcp_push_msgs() -> skb_send_sock_locked(), which reads the
> > > >     same skb as a data source.
> > > > 
> > > > Fix this by adding a synchronize_rcu() call after resetting sk_prot,
> > > > since esp_output_tcp_finish() runs under RCU and won't use a socket
> > > > with sk_prot == &tcp_prot.  Simply taking the socket lock in
> > > > espintcp_close() could lead to leaks, if esp_output_tcp_finish()
> > > > re-adds an skb in the slot we just freed. After this, the existing
> > > > barrier() is no longer needed.
> > > > 
> > > > Cc: stable@vger.kernel.org
> > > > Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
> > > > Reported-by: zdi-disclosures@trendmicro.com
> > > > Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> > > > Reviewed-by: Breno Leitao <leitao@debian.org>
> > > > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > > ---
> > > >  net/xfrm/espintcp.c |    3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > 
> > > > --- a/net/xfrm/espintcp.c
> > > > +++ b/net/xfrm/espintcp.c
> > > > @@ -506,7 +506,8 @@ static void espintcp_close(struct sock *
> > > >  	strp_stop(&ctx->strp);
> > > >  
> > > >  	sk->sk_prot = &tcp_prot;
> > > > -	barrier();
> > > > +
> > > > +	synchronize_rcu();
> > > 
> > > 
> > > This backport depends on upstream
> > > 028363685bd0 ("espintcp: remove encap socket caching to avoid reference leak"),
> > > which is not in 5.15.y. Without it, esp_find_tcp_sk() still
> > > returns the cached x->encap_sk based only on sk_state == TCP_ESTABLISHED
> > > (no tcp_is_ulp_esp() check), so new readers keep racing with
> > > espintcp_close()'s kfree_skb on ctx->partial.emsg->skb — the UAF issue
> > > this patch is supposed to fix.
> > > 
> > > Reproduced on 5.15.219+ (with this patch applied), KASAN trimmed:
> > > 
> > >   BUG: KASAN: use-after-free in __skb_send_sock+0x6cf/0x7b0
> > >   Workqueue: events xfrm_trans_reinject
> > > 
> > >   Reader:
> > >     __skb_send_sock <- espintcp_push_msgs <- espintcp_push_skb <-
> > >     esp_output_tcp_encap_cb <- xfrm_trans_reinject
> > > 
> > >   Free:
> > >     espintcp_close <- inet_release <- __sock_release <- sock_close <-
> > >     __fput
> > > 
> > >   Object: skbuff_head_cache (size 224), i.e. struct sk_buff.
> > > 
> > > Provenance: the static analysis (missing-prerequisite chain, code-path
> > > derivation) and the KASAN reproducer above were both produced by our
> > > internal AI-assisted backport triage pipeline. I have personally
> > > reviewed the reasoning line-by-line against the 5.15.y source, re-ran
> > > the reproducer end-to-end, and confirm the finding — sending it upstream
> > > on that basis.
> > 
> > That's LLM output, what do you mean to say here to fix this?  Please
> > send a patch...
> 
> Hi Greg,
> 
> Sorry about the confusion. Just to clarify, this is not raw LLM output.
> I only included that note to be transparent and avoid any controversy,
> as the issue wasn't initially discovered by myself.
> 
> We actually already have a patch prepared for this, but the situation is
> a bit more complicated.
> 
> The fix actually has two prerequisite dependencies:
> 
> Commit 028363685bd0 ("espintcp: remove encap socket caching to avoid reference leak"), as mentioned earlier.
> Commit e1512c1db9e8 ("espintcp: Fix race condition in espintcp_close()"), which relies on disable_work_sync() — an API that
> does not exist in the 5.10 tree.
> 
> To avoid expanding the blast radius, we chose to use an alternative
> approach in espintcp to replace the implementation of commit
> e1512c1db9e8: introducing a stopped flag and protecting both the flag
> check and schedule_work() under the existing out_queue.lock spinlock,
> achieving the same atomic synchronization effect as
> disable_work_sync().
> 
> However, doing this inevitably leads to code divergence between upstream
> and this tree for xfrm. I'm not sure what the xfrm folks' stance is on
> this. If the community feels this is overly complicated, I think it's
> also totally fine to just leave the patch here.

Please always take the upstream commits when ever possible.  But the
disable_work_sync() stuff is messier, so if you just wait a few more
months, it's not going to be an issue as the 5.10.y tree will be
end-of-life by then :)

So, why not move to a newer kernel tree now?

thanks,

greg k-h

  reply	other threads:[~2026-09-05 11:17 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 13:35 [PATCH 5.10 00/43] 5.10.269-rc1 review Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 01/43] RDMA/rxe: Fix OOB in free_rd_atomic_resources() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 02/43] ipv6: mcast: Fix use-after-free when processing MLD queries Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 03/43] ext4: dont enable DAX on new encrypted files Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 04/43] ipvs: reload ip header after head reallocation Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 05/43] io_uring/io-wq: fix worker accounting when canceling creation callbacks Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 06/43] bpf: Remove tst_run from lwt_seg6local_prog_ops Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 07/43] jfs: add check read-only before truncation in jfs_truncate_nolock() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 08/43] jfs: add check read-only before txBeginAnon() call Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 09/43] KVM: arm64: Prevent access to vCPU events before init Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 10/43] bpf: Fix use-after-free in offloaded map/prog info fill Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 11/43] Revert "PM: sleep: Use complete() in device_pm_sleep_init()" Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 12/43] selinux: switch two allocations to use kzalloc_objs() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 13/43] Revert "mtd: maps: vmu-flash: fix fault in unaligned fixup" Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 14/43] Revert "smb: client: use kvzalloc() for megabyte buffer in simple fallocate" Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 15/43] ipv4: igmp: Fix potential UAF in igmp_gq_start_timer() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 16/43] kcov: fix data corruption and race conditions on PREEMPT_RT Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 17/43] ext4: propagate errors from fast commit range replay Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 18/43] nilfs2: reject invalid block index in GC ioctl Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 19/43] nfc: nci: fix uninit-value in the RF discover/activated NTF handlers Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 20/43] HID: magicmouse: do not keep a stale msc->input if no input is claimed Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 21/43] nfc: nci: add data_len bound checks to activation parameter extractors Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 22/43] nvmet-tcp: bound SGL data length before allocating command buffers Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 23/43] HID: input: read battery capacity from its actual report offset Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 24/43] fpga: dfl: fme: add error handling Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 25/43] accessibility: speakup: unregister tty ldisc on later init failures Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 26/43] usb: usbtest: disable dynamic ID support Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 27/43] usb: gadget: f_tcm: keep port count until LUN teardown completes Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 28/43] xfrm: espintcp: fix UAF during close Greg Kroah-Hartman
2026-09-04  9:51   ` D. Wythe
2026-09-04 12:15     ` Greg Kroah-Hartman
2026-09-05 10:17       ` D. Wythe
2026-09-05 11:16         ` Greg Kroah-Hartman [this message]
2026-09-08  0:53         ` Sasha Levin
2026-09-06 13:32     ` Sasha Levin
2026-08-31 13:35 ` [PATCH 5.10 29/43] xfrm: drop ESP-in-TCP packets with no ingress device Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 30/43] xfrm: ah6: validate routing header segments_left Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 31/43] xfrm: fix xfrm_state_construct() auth-trunc leak Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 32/43] ipv6: seg6: clear IPv4 control block on IPIP decapsulation Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 33/43] mm/swap: reject swapon() on filesystem-level encrypted files Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 34/43] crypto: atmel-tdes - use scatterlist length before DMA mapping Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 35/43] crypto: mxs-dcp - fix source scatterlist length access Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 36/43] KVM: s390: vsie: zero stale crypto bits Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 37/43] usb: core: Add lock to usb_wakeup_notification() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 38/43] usb: core: Strengthen error handling in hub_hub_status() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 39/43] ALSA: usb-audio: fix OOB write in snd_usbmidi_novation_output() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 40/43] USB: serial: option: fix slab OOB read in interrupt URB callback Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 41/43] USB: serial: spcp8x5: drop broken carrier detect support Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 42/43] USB: c67x00: fix use-after-free in c67x00_add_iso_urb() Greg Kroah-Hartman
2026-08-31 13:35 ` [PATCH 5.10 43/43] usb: usbfs: fix use-after-free of usb_device in usbdev_release() Greg Kroah-Hartman
2026-08-31 17:01 ` [PATCH 5.10 00/43] 5.10.269-rc1 review Florian Fainelli
2026-08-31 19:23 ` Brett A C Sheffield
2026-08-31 20:58 ` Woody Suwalski
2026-09-01  2:00 ` Dominique Martinet
2026-09-01  8:45 ` Pavel Machek
2026-09-01 16:48 ` Shuah Khan
2026-09-02  0:11 ` Barry K. Nathan

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=2026090558-issue-factoid-6115@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=alibuda@linux.alibaba.com \
    --cc=leitao@debian.org \
    --cc=patches@lists.linux.dev \
    --cc=sd@queasysnail.net \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=zdi-disclosures@trendmicro.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