netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] [net?] WARNING in xfrm_state_migrate (2)
@ 2025-10-05 17:39 syzbot
  2025-10-14 13:26 ` Sabrina Dubroca
  0 siblings, 1 reply; 4+ messages in thread
From: syzbot @ 2025-10-05 17:39 UTC (permalink / raw)
  To: davem, edumazet, herbert, horms, kuba, linux-kernel, netdev,
	pabeni, steffen.klassert, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    4b946f6bb7d6 selftests/bpf: Fix realloc size in bpf_get_ad..
git tree:       bpf
console output: https://syzkaller.appspot.com/x/log.txt?x=13be46e2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=8f1ac8502efee0ee
dashboard link: https://syzkaller.appspot.com/bug?extid=5cd6299ede4d4f70987b
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f0ef71bdead6/disk-4b946f6b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/0c8251d5df12/vmlinux-4b946f6b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/29bad3cdad16/bzImage-4b946f6b.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+5cd6299ede4d4f70987b@syzkaller.appspotmail.com

------------[ cut here ]------------
WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 __xfrm_state_destroy net/xfrm/xfrm_state.c:800 [inline]
WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_put include/net/xfrm.h:928 [inline]
WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_migrate+0x13bc/0x1b10 net/xfrm/xfrm_state.c:2165
Modules linked in:
CPU: 0 UID: 0 PID: 30386 Comm: syz.6.7969 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025
RIP: 0010:__xfrm_state_destroy net/xfrm/xfrm_state.c:800 [inline]
RIP: 0010:xfrm_state_put include/net/xfrm.h:928 [inline]
RIP: 0010:xfrm_state_migrate+0x13bc/0x1b10 net/xfrm/xfrm_state.c:2165
Code: da fd de f7 90 0f 0b 90 e9 ab fa ff ff e8 cc fd de f7 4c 89 f7 be 03 00 00 00 e8 0f f0 a4 fa e9 77 fb ff ff e8 b5 fd de f7 90 <0f> 0b 90 e9 f6 fe ff ff e8 a7 fd de f7 eb d9 44 89 f1 80 e1 07 38
RSP: 0018:ffffc90003afecc0 EFLAGS: 00010287
RAX: ffffffff89df782b RBX: ffff888029ffc880 RCX: 0000000000080000
RDX: ffffc90020769000 RSI: 0000000000000213 RDI: 0000000000000214
RBP: 0000000000000001 R08: ffff888029ffc8eb R09: 1ffff110053ff91d
R10: dffffc0000000000 R11: ffffed10053ff91e R12: dffffc0000000000
R13: 1ffff9200075fe2a R14: ffff888029ffc8e8 R15: ffff888079932200
FS:  00007fe59aadf6c0(0000) GS:ffff888126373000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000110c31a411 CR3: 00000000280be000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000200000000300
DR3: 0000000000000000 DR6: 00000000ffff0ff1 DR7: 0000000000000600
Call Trace:
 <TASK>
 xfrm_migrate+0xefa/0x2330 net/xfrm/xfrm_policy.c:4669
 xfrm_do_migrate+0x796/0x900 net/xfrm/xfrm_user.c:3144
 xfrm_user_rcv_msg+0x7a0/0xab0 net/xfrm/xfrm_user.c:3501
 netlink_rcv_skb+0x205/0x470 net/netlink/af_netlink.c:2552
 xfrm_netlink_rcv+0x79/0x90 net/xfrm/xfrm_user.c:3523
 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline]
 netlink_unicast+0x82f/0x9e0 net/netlink/af_netlink.c:1346
 netlink_sendmsg+0x805/0xb30 net/netlink/af_netlink.c:1896
 sock_sendmsg_nosec net/socket.c:714 [inline]
 __sock_sendmsg+0x219/0x270 net/socket.c:729
 ____sys_sendmsg+0x505/0x830 net/socket.c:2617
 ___sys_sendmsg+0x21f/0x2a0 net/socket.c:2671
 __sys_sendmsg net/socket.c:2703 [inline]
 __do_sys_sendmsg net/socket.c:2708 [inline]
 __se_sys_sendmsg net/socket.c:2706 [inline]
 __x64_sys_sendmsg+0x19b/0x260 net/socket.c:2706
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe599b8eec9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe59aadf038 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007fe599de6090 RCX: 00007fe599b8eec9
RDX: 0000000000042000 RSI: 0000200000000380 RDI: 0000000000000005
RBP: 00007fe599c11f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fe599de6128 R14: 00007fe599de6090 R15: 00007ffdb88a6108
 </TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] [net?] WARNING in xfrm_state_migrate (2)
  2025-10-05 17:39 [syzbot] [net?] WARNING in xfrm_state_migrate (2) syzbot
@ 2025-10-14 13:26 ` Sabrina Dubroca
  2025-10-15  7:43   ` Steffen Klassert
  0 siblings, 1 reply; 4+ messages in thread
From: Sabrina Dubroca @ 2025-10-14 13:26 UTC (permalink / raw)
  To: steffen.klassert, syzbot
  Cc: davem, edumazet, herbert, horms, kuba, linux-kernel, netdev,
	pabeni, syzkaller-bugs

2025-10-05, 10:39:46 -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    4b946f6bb7d6 selftests/bpf: Fix realloc size in bpf_get_ad..
> git tree:       bpf
> console output: https://syzkaller.appspot.com/x/log.txt?x=13be46e2580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=8f1ac8502efee0ee
> dashboard link: https://syzkaller.appspot.com/bug?extid=5cd6299ede4d4f70987b
> compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
> 
> Unfortunately, I don't have any reproducer for this issue yet.
> 
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/f0ef71bdead6/disk-4b946f6b.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/0c8251d5df12/vmlinux-4b946f6b.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/29bad3cdad16/bzImage-4b946f6b.xz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+5cd6299ede4d4f70987b@syzkaller.appspotmail.com
> 
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 __xfrm_state_destroy net/xfrm/xfrm_state.c:800 [inline]
> WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_put include/net/xfrm.h:928 [inline]
> WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_migrate+0x13bc/0x1b10 net/xfrm/xfrm_state.c:2165

Steffen, this looks like we simply forgot to set XFRM_STATE_DEAD
before the final put() in the error path of xfrm_state_migrate (and
xfrm_state_clone_and_setup):


diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 9ea1d45b79e3..7ae10fac7b31 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2074,6 +2074,7 @@ static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig,
 	return x;
 
  error:
+	x->km.state = XFRM_STATE_DEAD;
 	xfrm_state_put(x);
 out:
 	return NULL;
@@ -2163,6 +2164,7 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
 
 	return xc;
 error:
+	xc->km.state = XFRM_STATE_DEAD;
 	xfrm_state_put(xc);
 	return NULL;
 }


Does that look reasonable? The state was never add()/insert()'ed, so
it goes through put()/destroy() without delete() first that would set
XFRM_STATE_DEAD.


It also looks like we're missing a xfrm_dev_state_delete if
xfrm_state_migrate -> xfrm_state_add fails, since
xfrm_dev_state_delete gets called during __xfrm_state_delete, and this
new state will only see xfrm_state_put/__xfrm_state_destroy:

@@ -2159,10 +2159,13 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
 		xfrm_state_insert(xc);
 	} else {
 		if (xfrm_state_add(xc) < 0)
-			goto error;
+			goto error_add;
 	}
 
 	return xc;
+error_add:
+	if (xuo)
+		xfrm_dev_state_delete(xc);
 error:
 	xc->km.state = XFRM_STATE_DEAD;
 	xfrm_state_put(xc);


-- 
Sabrina

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [syzbot] [net?] WARNING in xfrm_state_migrate (2)
  2025-10-14 13:26 ` Sabrina Dubroca
@ 2025-10-15  7:43   ` Steffen Klassert
  2025-10-15  9:53     ` Sabrina Dubroca
  0 siblings, 1 reply; 4+ messages in thread
From: Steffen Klassert @ 2025-10-15  7:43 UTC (permalink / raw)
  To: Sabrina Dubroca
  Cc: syzbot, davem, edumazet, herbert, horms, kuba, linux-kernel,
	netdev, pabeni, syzkaller-bugs

On Tue, Oct 14, 2025 at 03:26:53PM +0200, Sabrina Dubroca wrote:
> 2025-10-05, 10:39:46 -0700, syzbot wrote:
> > Hello,
> > 
> > syzbot found the following issue on:
> > 
> > HEAD commit:    4b946f6bb7d6 selftests/bpf: Fix realloc size in bpf_get_ad..
> > git tree:       bpf
> > console output: https://syzkaller.appspot.com/x/log.txt?x=13be46e2580000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=8f1ac8502efee0ee
> > dashboard link: https://syzkaller.appspot.com/bug?extid=5cd6299ede4d4f70987b
> > compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
> > 
> > Unfortunately, I don't have any reproducer for this issue yet.
> > 
> > Downloadable assets:
> > disk image: https://storage.googleapis.com/syzbot-assets/f0ef71bdead6/disk-4b946f6b.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/0c8251d5df12/vmlinux-4b946f6b.xz
> > kernel image: https://storage.googleapis.com/syzbot-assets/29bad3cdad16/bzImage-4b946f6b.xz
> > 
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+5cd6299ede4d4f70987b@syzkaller.appspotmail.com
> > 
> > ------------[ cut here ]------------
> > WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 __xfrm_state_destroy net/xfrm/xfrm_state.c:800 [inline]
> > WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_put include/net/xfrm.h:928 [inline]
> > WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_migrate+0x13bc/0x1b10 net/xfrm/xfrm_state.c:2165
> 
> Steffen, this looks like we simply forgot to set XFRM_STATE_DEAD
> before the final put() in the error path of xfrm_state_migrate (and
> xfrm_state_clone_and_setup):
> 
> 
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 9ea1d45b79e3..7ae10fac7b31 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -2074,6 +2074,7 @@ static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig,
>  	return x;
>  
>   error:
> +	x->km.state = XFRM_STATE_DEAD;
>  	xfrm_state_put(x);
>  out:
>  	return NULL;
> @@ -2163,6 +2164,7 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
>  
>  	return xc;
>  error:
> +	xc->km.state = XFRM_STATE_DEAD;
>  	xfrm_state_put(xc);
>  	return NULL;
>  }
> 
> 
> Does that look reasonable? The state was never add()/insert()'ed, so
> it goes through put()/destroy() without delete() first that would set
> XFRM_STATE_DEAD.

Right. Looks like this is broken since the migrate API exists.

> It also looks like we're missing a xfrm_dev_state_delete if
> xfrm_state_migrate -> xfrm_state_add fails, since
> xfrm_dev_state_delete gets called during __xfrm_state_delete, and this
> new state will only see xfrm_state_put/__xfrm_state_destroy:
> 
> @@ -2159,10 +2159,13 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
>  		xfrm_state_insert(xc);
>  	} else {
>  		if (xfrm_state_add(xc) < 0)
> -			goto error;
> +			goto error_add;
>  	}
>  
>  	return xc;
> +error_add:
> +	if (xuo)
> +		xfrm_dev_state_delete(xc);

This is correct as well. Thanks for catching these!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] [net?] WARNING in xfrm_state_migrate (2)
  2025-10-15  7:43   ` Steffen Klassert
@ 2025-10-15  9:53     ` Sabrina Dubroca
  0 siblings, 0 replies; 4+ messages in thread
From: Sabrina Dubroca @ 2025-10-15  9:53 UTC (permalink / raw)
  To: Steffen Klassert
  Cc: syzbot, davem, edumazet, herbert, horms, kuba, linux-kernel,
	netdev, pabeni, syzkaller-bugs

2025-10-15, 09:43:12 +0200, Steffen Klassert wrote:
> On Tue, Oct 14, 2025 at 03:26:53PM +0200, Sabrina Dubroca wrote:
> > 2025-10-05, 10:39:46 -0700, syzbot wrote:
> > > Hello,
> > > 
> > > syzbot found the following issue on:
> > > 
> > > HEAD commit:    4b946f6bb7d6 selftests/bpf: Fix realloc size in bpf_get_ad..
> > > git tree:       bpf
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=13be46e2580000
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=8f1ac8502efee0ee
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=5cd6299ede4d4f70987b
> > > compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
> > > 
> > > Unfortunately, I don't have any reproducer for this issue yet.
> > > 
> > > Downloadable assets:
> > > disk image: https://storage.googleapis.com/syzbot-assets/f0ef71bdead6/disk-4b946f6b.raw.xz
> > > vmlinux: https://storage.googleapis.com/syzbot-assets/0c8251d5df12/vmlinux-4b946f6b.xz
> > > kernel image: https://storage.googleapis.com/syzbot-assets/29bad3cdad16/bzImage-4b946f6b.xz
> > > 
> > > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > > Reported-by: syzbot+5cd6299ede4d4f70987b@syzkaller.appspotmail.com
> > > 
> > > ------------[ cut here ]------------
> > > WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 __xfrm_state_destroy net/xfrm/xfrm_state.c:800 [inline]
> > > WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_put include/net/xfrm.h:928 [inline]
> > > WARNING: CPU: 0 PID: 30386 at net/xfrm/xfrm_state.c:800 xfrm_state_migrate+0x13bc/0x1b10 net/xfrm/xfrm_state.c:2165
> > 
> > Steffen, this looks like we simply forgot to set XFRM_STATE_DEAD
> > before the final put() in the error path of xfrm_state_migrate (and
> > xfrm_state_clone_and_setup):
> > 
> > 
> > diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> > index 9ea1d45b79e3..7ae10fac7b31 100644
> > --- a/net/xfrm/xfrm_state.c
> > +++ b/net/xfrm/xfrm_state.c
> > @@ -2074,6 +2074,7 @@ static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig,
> >  	return x;
> >  
> >   error:
> > +	x->km.state = XFRM_STATE_DEAD;
> >  	xfrm_state_put(x);
> >  out:
> >  	return NULL;
> > @@ -2163,6 +2164,7 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
> >  
> >  	return xc;
> >  error:
> > +	xc->km.state = XFRM_STATE_DEAD;
> >  	xfrm_state_put(xc);
> >  	return NULL;
> >  }
> > 
> > 
> > Does that look reasonable? The state was never add()/insert()'ed, so
> > it goes through put()/destroy() without delete() first that would set
> > XFRM_STATE_DEAD.
> 
> Right. Looks like this is broken since the migrate API exists.
> 
> > It also looks like we're missing a xfrm_dev_state_delete if
> > xfrm_state_migrate -> xfrm_state_add fails, since
> > xfrm_dev_state_delete gets called during __xfrm_state_delete, and this
> > new state will only see xfrm_state_put/__xfrm_state_destroy:
> > 
> > @@ -2159,10 +2159,13 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
> >  		xfrm_state_insert(xc);
> >  	} else {
> >  		if (xfrm_state_add(xc) < 0)
> > -			goto error;
> > +			goto error_add;
> >  	}
> >  
> >  	return xc;
> > +error_add:
> > +	if (xuo)
> > +		xfrm_dev_state_delete(xc);
> 
> This is correct as well. Thanks for catching these!

Thanks for confirming. I'll post the patches (with a few other fixes I
have) today or tomorrow.

-- 
Sabrina

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-15  9:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-05 17:39 [syzbot] [net?] WARNING in xfrm_state_migrate (2) syzbot
2025-10-14 13:26 ` Sabrina Dubroca
2025-10-15  7:43   ` Steffen Klassert
2025-10-15  9:53     ` Sabrina Dubroca

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).