From: Yu Junzhe <junzheyu1@gmail.com>
To: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, ipsec@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [BUG] espintcp: slab UAF in espintcp_tx_work after espintcp_close
Date: Tue, 1 Dec 2026 03:14:15 +0000 [thread overview]
Message-ID: <20261201031415.194-1-junzheyu1@gmail.com> (raw)
Hello,
I am reporting a slab use-after-free in espintcp_tx_work(). A TCP socket
with the "espintcp" ULP can be closed while an ACK still schedules
ctx->work after cancel_work_sync() in espintcp_close(), and
espintcp_destruct() frees the context before the worker runs.
Summary
=======
espintcp_write_space() calls schedule_work(&ctx->work). espintcp_close()
waits with cancel_work_sync() and then tcp_close() frees the context from
espintcp_destruct(). cancel_work_sync() does not block later schedule_work()
calls.
On 6.6, a write-space callback from tcp_check_space() (for example while
ksoftirqd processes an inbound segment right after cancel_work_sync()
returns) can queue espintcp_tx_work() again. The worker then reads
ctx->tx_running at espintcp.c:415 on freed kmalloc memory.
Affected
========
- Originally observed: Linux 6.6.158 KASAN
- Still vulnerable in source: 6.6.163, 6.1.193, 5.15.226
(cancel_work_sync in espintcp_close; no disable_work_sync)
- Fixed in mainline: e1512c1db9e8 "espintcp: Fix race condition in
espintcp_close()" (disable_work_sync); present on 7.4-rc5, 6.18.65,
6.12.119
- Config: CONFIG_INET_ESPINTCP=y, CONFIG_KASAN=y
- Files: net/xfrm/espintcp.c
Crash excerpt (campaign, Linux 6.6.158)
=======================================
BUG: KASAN: slab-use-after-free in espintcp_tx_work+0x9f/0xb0
Read of size 1 by task kworker/1:1
Workqueue: events espintcp_tx_work
Allocated: espintcp_init_sk via tcp_set_ulp
Freed: espintcp_destruct during tcp_close / do_exit
Last work creation: espintcp_write_space from tcp_check_space in
tcp_rcv_established on ksoftirqd
A self-contained Docker/QEMU PoC attaches TCP_ULP "espintcp" on loopback,
keeps the peer sending while the client closes, and stresses the race. I can
send the package or test a backport of e1512c1db9e8.
Thanks,
Yu Junzhe
FuzzAnything <fuzzanything@gmail.com>
reply other threads:[~2026-12-01 3:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201031415.194-1-junzheyu1@gmail.com \
--to=junzheyu1@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=ipsec@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--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