syzbot


BUG: sleeping function called from invalid context in smc_pnet_add

Status: internal: reported C repro on 2022/02/06 13:40
Reported-by: syzbot+@syzkaller.appspotmail.com
Fix commit: 94fdd7c02a56 net/smc: use GFP_ATOMIC allocation in smc_pnet_add_eth()
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 142d, last: 141d

Cause bisection: introduced by (bisect log) :
commit 28f9222138868899c53e00bc1f910faa55f88546
Author: Eric Dumazet <edumazet@google.com>
Date: Sun Feb 6 05:05:16 2022 +0000

  net/smc: fix ref_tracker issue in smc_pnet_add()

Crash: BUG: sleeping function called from invalid context in smc_pnet_add (log)
Repro: C syz .config

Sample crash report:
netdevsim netdevsim0 netdevsim1: set [1, 0] type 2 family 0 port 6081 - 0
netdevsim netdevsim0 netdevsim2: set [1, 0] type 2 family 0 port 6081 - 0
netdevsim netdevsim0 netdevsim3: set [1, 0] type 2 family 0 port 6081 - 0
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:256
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 3590, name: syz-executor266
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
3 locks held by syz-executor266/3590:
 #0: ffffffff8d3c09f0 (cb_lock){++++}-{3:3}, at: genl_rcv+0x15/0x40 net/netlink/genetlink.c:802
 #1: ffffffff8d3c0aa8 (genl_mutex){+.+.}-{3:3}, at: genl_lock net/netlink/genetlink.c:33 [inline]
 #1: ffffffff8d3c0aa8 (genl_mutex){+.+.}-{3:3}, at: genl_rcv_msg+0x3e0/0x580 net/netlink/genetlink.c:790
 #2: ffff888015bd8318 (&pnettable->lock){+.+.}-{2:2}, at: smc_pnet_add_eth net/smc/smc_pnet.c:373 [inline]
 #2: ffff888015bd8318 (&pnettable->lock){+.+.}-{2:2}, at: smc_pnet_enter net/smc/smc_pnet.c:495 [inline]
 #2: ffff888015bd8318 (&pnettable->lock){+.+.}-{2:2}, at: smc_pnet_add+0x46e/0x1710 net/smc/smc_pnet.c:558
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 1 PID: 3590 Comm: syz-executor266 Not tainted 5.17.0-rc2-syzkaller-00180-g28f922213886 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 __might_resched.cold+0x222/0x26b kernel/sched/core.c:9576
 might_alloc include/linux/sched/mm.h:256 [inline]
 slab_pre_alloc_hook mm/slab.h:705 [inline]
 slab_alloc_node mm/slub.c:3144 [inline]
 slab_alloc mm/slub.c:3238 [inline]
 kmem_cache_alloc_trace+0x25d/0x2c0 mm/slub.c:3255
 kmalloc include/linux/slab.h:581 [inline]
 kzalloc include/linux/slab.h:715 [inline]
 ref_tracker_alloc+0x10a/0x460 lib/ref_tracker.c:77
 netdev_tracker_alloc include/linux/netdevice.h:3860 [inline]
 smc_pnet_add_eth net/smc/smc_pnet.c:384 [inline]
 smc_pnet_enter net/smc/smc_pnet.c:495 [inline]
 smc_pnet_add+0x78f/0x1710 net/smc/smc_pnet.c:558
 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:731
 genl_family_rcv_msg net/netlink/genetlink.c:775 [inline]
 genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:792
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
 netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343
 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:705 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:725
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2413
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2496
 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+0x44/0xae
RIP: 0033:0x7f979ef8b4a9
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:00007fffc3499db8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007fffc3499dc8 RCX: 00007f979ef8b4a9

Crashes (45):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-net-this-kasan-gce 2022/02/06 20:45 net 28f922213886 a7dab638 .config log report syz C BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 11:53 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 10:50 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 10:50 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 10:49 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 10:45 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 10:40 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 10:40 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 10:25 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 08:41 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 07:19 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 07:06 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 06:43 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 06:42 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 06:42 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 06:39 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 05:05 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 04:50 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 04:41 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 04:15 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 03:40 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 03:17 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 03:17 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 03:07 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/07 02:37 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 23:18 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 22:52 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 22:43 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 22:27 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 19:14 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 17:55 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 17:36 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 15:30 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 15:28 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 15:23 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 15:21 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 15:00 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 14:30 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 14:18 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 14:17 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 14:06 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add
ci-upstream-net-this-kasan-gce 2022/02/06 13:39 net 28f922213886 a7dab638 .config log report info BUG: sleeping function called from invalid context in smc_pnet_add