[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aKyIZhcJBH1WyKYQ@krikkit>
Date: Mon, 25 Aug 2025 17:59:34 +0200
From: Sabrina Dubroca <sd@...asysnail.net>
To: syzbot <syzbot+a25ee9d20d31e483ba7b@...kaller.appspotmail.com>,
Aakash Kumar S <saakashkumar@...vell.com>,
steffen.klassert@...unet.com, herbert@...dor.apana.org.au
Cc: davem@...emloft.net, edumazet@...gle.com, horms@...nel.org,
kuba@...nel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, pabeni@...hat.com,
syzkaller-bugs@...glegroups.com
Subject: Re: [syzbot] [net?] KASAN: slab-use-after-free Write in
__xfrm_state_delete
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
Powered by blists - more mailing lists