From: Sabrina Dubroca <sd@queasysnail.net>
To: syzbot <syzbot+a25ee9d20d31e483ba7b@syzkaller.appspotmail.com>,
Aakash Kumar S <saakashkumar@marvell.com>,
steffen.klassert@secunet.com, herbert@gondor.apana.org.au
Cc: davem@davemloft.net, edumazet@google.com, horms@kernel.org,
kuba@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [net?] KASAN: slab-use-after-free Write in __xfrm_state_delete
Date: Mon, 25 Aug 2025 17:59:34 +0200 [thread overview]
Message-ID: <aKyIZhcJBH1WyKYQ@krikkit> (raw)
In-Reply-To: <68ab6633.050a0220.37038e.0079.GAE@google.com>
2025-08-24, 12:21:23 -0700, syzbot wrote:
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: b1c92cdf5af3 Merge branch 'net-wangxun-complete-ethtool-co..
> git tree: net-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=1411b062580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=67b99ceb67d33475
> dashboard link: https://syzkaller.appspot.com/bug?extid=a25ee9d20d31e483ba7b
> compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14221862580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=159fba34580000
This splat seems to be caused by commit 94f39804d891 ("xfrm: Duplicate
SPI Handling"), which removed the "newspi != 0" check before inserting
the state on the byspi list. But __xfrm_state_delete will only remove
states (in this case, when they expire) from the byspi list if
x->id.spi != 0.
So maybe something like this?
-------- 8< --------
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 78fcbb89cf32..d213ca3653a8 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2583,6 +2583,8 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high,
for (h = 0; h < range; h++) {
u32 spi = (low == high) ? low : get_random_u32_inclusive(low, high);
+ if (spi == 0)
+ goto next;
newspi = htonl(spi);
spin_lock_bh(&net->xfrm.xfrm_state_lock);
@@ -2598,6 +2600,7 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high,
xfrm_state_put(x0);
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
+next:
if (signal_pending(current)) {
err = -ERESTARTSYS;
goto unlock;
--
Sabrina
next prev parent reply other threads:[~2025-08-25 15:59 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 7:08 [syzbot] [net?] KASAN: slab-use-after-free Write in __xfrm_state_delete syzbot
2025-08-24 19:21 ` syzbot
2025-08-25 1:10 ` Hillf Danton
2025-08-25 1:51 ` syzbot
2025-08-25 4:51 ` Hillf Danton
2025-08-25 12:33 ` syzbot
2025-08-25 12:44 ` Hillf Danton
2025-08-25 14:13 ` syzbot
2025-08-25 15:59 ` Sabrina Dubroca [this message]
2025-08-26 3:27 ` Hillf Danton
2025-08-26 3:53 ` syzbot
2025-08-26 4:16 ` Hillf Danton
2025-08-26 5:12 ` syzbot
2025-08-26 7:31 ` Hillf Danton
2025-08-26 11:11 ` syzbot
2025-08-26 9:41 ` Edward Adam Davis
2025-08-26 11:34 ` syzbot
2025-08-26 13:22 ` Hillf Danton
2025-08-26 19:54 ` syzbot
2025-08-27 0:40 ` Hillf Danton
2025-08-27 2:44 ` syzbot
2025-08-27 1:30 ` Edward Adam Davis
2025-08-27 3:03 ` syzbot
2025-08-27 4:51 ` Hillf Danton
2025-08-27 6:27 ` syzbot
2025-08-27 5:18 ` Hillf Danton
2025-08-27 6:44 ` syzbot
2025-08-27 5:49 ` Edward Adam Davis
2025-08-27 6:44 ` syzbot
2025-08-27 6:56 ` Edward Adam Davis
2025-08-27 7:26 ` syzbot
2025-08-27 7:57 ` Hillf Danton
2025-08-27 8:22 ` syzbot
2025-08-27 8:10 ` Edward Adam Davis
2025-08-27 9:14 ` syzbot
2025-08-27 8:39 ` Hillf Danton
2025-08-27 9:31 ` syzbot
2025-08-27 9:35 ` Edward Adam Davis
2025-08-27 10:23 ` syzbot
2025-08-27 10:07 ` Hillf Danton
2025-08-27 10:41 ` syzbot
2025-08-27 11:00 ` Hillf Danton
2025-08-27 11:48 ` syzbot
2025-08-28 7:25 ` syzbot
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=aKyIZhcJBH1WyKYQ@krikkit \
--to=sd@queasysnail.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saakashkumar@marvell.com \
--cc=steffen.klassert@secunet.com \
--cc=syzbot+a25ee9d20d31e483ba7b@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).