[syzbot] WARNING in nsim_map_alloc_elem

From: syzbot
Date: Sun Jul 24 2022 - 06:41:33 EST


Hello,

syzbot found the following issue on:

HEAD commit: b77ffb30cfc5 libbpf: fix an snprintf() overflow check
git tree: bpf-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=16a7f652080000
kernel config: https://syzkaller.appspot.com/x/.config?x=386b986585586629
dashboard link: https://syzkaller.appspot.com/bug?extid=ad24705d3fd6463b18c6
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=102ad7c6080000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16d71a9c080000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+ad24705d3fd6463b18c6@xxxxxxxxxxxxxxxxxxxxxxxxx

------------[ cut here ]------------
WARNING: CPU: 0 PID: 3609 at mm/page_alloc.c:5402 __alloc_pages+0x39e/0x510 mm/page_alloc.c:5402
Modules linked in:
CPU: 0 PID: 3609 Comm: syz-executor427 Not tainted 5.19.0-rc5-syzkaller-01146-gb77ffb30cfc5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022
RIP: 0010:__alloc_pages+0x39e/0x510 mm/page_alloc.c:5402
Code: ff ff 00 0f 84 33 fe ff ff 80 ce 01 e9 2b fe ff ff 83 fe 0a 0f 86 3e fd ff ff 80 3d d2 70 e9 0b 00 75 09 c6 05 c9 70 e9 0b 01 <0f> 0b 45 31 f6 e9 8d fe ff ff 65 ff 05 21 55 45 7e 48 c7 c0 a0 16
RSP: 0018:ffffc900030cf9c0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 1ffff92000619f39 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 000000000000000b RDI: 0000000000000000
RBP: 0000000000140cc0 R08: 0000000000000007 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: 000000000000000b
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000400002
FS: 0000555556dfc300(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000001b8ef000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
kmalloc_order+0x34/0xf0 mm/slab_common.c:945
kmalloc_order_trace+0x14/0x120 mm/slab_common.c:961
kmalloc include/linux/slab.h:605 [inline]
nsim_map_alloc_elem+0x119/0x2e0 drivers/net/netdevsim/bpf.c:357
nsim_bpf_map_alloc drivers/net/netdevsim/bpf.c:512 [inline]
nsim_bpf+0x8b3/0x1050 drivers/net/netdevsim/bpf.c:573
bpf_map_offload_ndo+0x132/0x1e0 kernel/bpf/offload.c:359
bpf_map_offload_map_alloc+0x243/0x450 kernel/bpf/offload.c:394
find_and_alloc_map kernel/bpf/syscall.c:131 [inline]
map_create kernel/bpf/syscall.c:1102 [inline]
__sys_bpf+0x8b8/0x5750 kernel/bpf/syscall.c:4936
__do_sys_bpf kernel/bpf/syscall.c:5058 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5056 [inline]
__x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:5056
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f1f9a4a1ba9
Code: 28 c3 e8 4a 15 00 00 66 2e 0f 1f 84 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffebe3a1e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fffebe3a1f8 RCX: 00007f1f9a4a1ba9
RDX: 0000000000000048 RSI: 0000000020000100 RDI: 0000000000000000
RBP: 0000000000000003 R08: bb1414ac00000000 R09: bb1414ac00000000
R10: bb1414ac00000000 R11: 0000000000000246 R12: 00007fffebe3a200
R13: 00007fffebe3a1f4 R14: 0000000000000003 R15: 0000000000000000
</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@xxxxxxxxxxxxxxxx.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches