Thread (2 messages) 2 messages, 2 authors, 2025-05-02

Re: [syzbot] [net?] UBSAN: array-index-out-of-bounds in ipv6_addr_prefix

flat view

From: Kuniyuki Iwashima <hidden>
Date: 2025-05-02 00:26:32
Also in: lkml
Subsystem: networking [general], networking [ipv4/ipv6], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern, Ido Schimmel, Linus Torvalds

From: syzbot <redacted>
Date: Thu, 01 May 2025 04:15:34 -0700
Hello,

syzbot found the following issue on:

HEAD commit:    5565acd1e6c4 Merge git://git.kernel.org/pub/scm/linux/kern..
git tree:       net-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=12f19574580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=2e3745cb659ef5d9
dashboard link: https://syzkaller.appspot.com/bug?extid=e4eec4b8584ac3f936e5
compiler:       Debian clang version 20.1.2 (++20250402124445+58df0ef89dd6-1~exp1~20250402004600.97), Debian LLD 20.1.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=10207fcf980000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16f19574580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/80798769614c/disk-5565acd1.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/435ecb0f1371/vmlinux-5565acd1.xz
kernel image: https://storage.googleapis.com/syzbot-assets/7790d5f923b6/bzImage-5565acd1.xz

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

------------[ cut here ]------------
UBSAN: array-index-out-of-bounds in ./include/net/ipv6.h:616:21
index 16 is out of range for type 'const __u8[16]' (aka 'const unsigned char[16]')
CPU: 0 UID: 0 PID: 5837 Comm: syz-executor401 Not tainted 6.15.0-rc3-syzkaller-00557-g5565acd1e6c4 #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 ubsan_epilogue+0xa/0x40 lib/ubsan.c:231
 __ubsan_handle_out_of_bounds+0xe9/0xf0 lib/ubsan.c:453
 ipv6_addr_prefix+0x145/0x1d0 include/net/ipv6.h:616
 ip6_route_info_create+0x629/0xa70 net/ipv6/route.c:3814
 ip6_route_mpath_info_create net/ipv6/route.c:5393 [inline]
 ip6_route_multipath_add net/ipv6/route.c:5519 [inline]
I missed err is reset by rtm_to_fib6_multipath_config()
and lwtunnel_valid_encap_type() ... I like setting
err just before goto...

so the diff below fixes,

---8<---
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index aa6b45bd3515..fee80b08bc46 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5275,6 +5275,8 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
 	}
 
 	if (newroute) {
+		err = -EINVAL;
+
 		/* RTF_PCPU is an internal flag; can not be set by userspace */
 		if (cfg->fc_flags & RTF_PCPU) {
 			NL_SET_ERR_MSG(extack, "Userspace can not set RTF_PCPU");
---8<---
but this patch also fixes it,

https://lore.kernel.org/netdev/20250501005335.53683-1-kuniyu@amazon.com/ (local)

so,

#syz dup: [syzbot] [net?] WARNING in ipv6_addr_prefix
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help