syzbot


possible deadlock in kcm_ioctl

Status: fixed on 2023/02/24 13:50
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+e696806ef96cdd2d87cd@syzkaller.appspotmail.com
Fix commit: 8fc29ff3910f kcm: fix strp_init() order and cleanup
First crash: 849d, last: 843d
Cause bisection: failed (error log, bisect log)
  
Discussions (9)
Title Replies (including bot) Last reply
[PATCH 5.4 000/108] 5.4.212-rc1 review 114 (114) 2022/09/17 03:06
[PATCH 4.19 00/79] 4.19.257-rc1 review 88 (88) 2022/09/17 02:04
[PATCH 5.15 000/107] 5.15.66-rc1 review 131 (131) 2022/09/16 16:25
[PATCH 4.14 00/61] 4.14.293-rc1 review 64 (64) 2022/09/15 00:15
[PATCH 5.19 000/155] 5.19.8-rc1 review 167 (167) 2022/09/08 09:40
[PATCH 5.10 00/80] 5.10.142-rc1 review 88 (88) 2022/09/08 04:04
[Patch net v2] kcm: fix strp_init() order and cleanup 2 (2) 2022/08/31 19:20
[Patch net] kcm: get rid of unnecessary cleanup 2 (2) 2022/08/23 23:39
[syzbot] possible deadlock in kcm_ioctl 0 (1) 2022/08/21 06:24
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 possible deadlock in kcm_ioctl C 1178 654d 1773d 0/1 upstream: reported C repro on 2020/02/04 19:56
Last patch testing requests (1)
Created Duration User Patch Repo Result
2022/08/21 11:31 16m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 95d10484d66e OK log

Sample crash report:
nf_conntrack: default automatic helper assignment has been turned off for security reasons and CT-based firewall rule not found. Use the iptables CT target to attach helpers instead.
======================================================
WARNING: possible circular locking dependency detected
6.0.0-rc1-next-20220819-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor244/3609 is trying to acquire lock:
ffff88807015c0f8 ((work_completion)(&strp->work)){+.+.}-{0:0}, at: __flush_work+0xdd/0xae0 kernel/workqueue.c:3066

but task is already holding lock:
ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1712 [inline]
ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: kcm_attach net/kcm/kcmsock.c:1390 [inline]
ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: kcm_ioctl+0x396/0x1180 net/kcm/kcmsock.c:1696

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (sk_lock-AF_INET){+.+.}-{0:0}:
       lock_sock_nested+0x36/0xf0 net/core/sock.c:3391
       do_strp_work net/strparser/strparser.c:398 [inline]
       strp_work+0x40/0x130 net/strparser/strparser.c:415
       process_one_work+0x991/0x1610 kernel/workqueue.c:2289
       worker_thread+0x665/0x1080 kernel/workqueue.c:2436
       kthread+0x2e4/0x3a0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

-> #0 ((work_completion)(&strp->work)){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3095 [inline]
       check_prevs_add kernel/locking/lockdep.c:3214 [inline]
       validate_chain kernel/locking/lockdep.c:3829 [inline]
       __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
       lock_acquire kernel/locking/lockdep.c:5666 [inline]
       lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
       __flush_work+0x105/0xae0 kernel/workqueue.c:3069
       __cancel_work_timer+0x3f9/0x570 kernel/workqueue.c:3160
       strp_done+0x64/0xf0 net/strparser/strparser.c:513
       kcm_attach net/kcm/kcmsock.c:1429 [inline]
       kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
       kcm_ioctl+0x913/0x1180 net/kcm/kcmsock.c:1696
       sock_do_ioctl+0xcc/0x230 net/socket.c:1169
       sock_ioctl+0x2f1/0x640 net/socket.c:1286
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl fs/ioctl.c:856 [inline]
       __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
       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+0x63/0xcd

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sk_lock-AF_INET);
                               lock((work_completion)(&strp->work));
                               lock(sk_lock-AF_INET);
  lock((work_completion)(&strp->work));

 *** DEADLOCK ***

1 lock held by syz-executor244/3609:
 #0: ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1712 [inline]
 #0: ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: kcm_attach net/kcm/kcmsock.c:1390 [inline]
 #0: ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
 #0: ffff888026939930 (sk_lock-AF_INET){+.+.}-{0:0}, at: kcm_ioctl+0x396/0x1180 net/kcm/kcmsock.c:1696

stack backtrace:
CPU: 0 PID: 3609 Comm: syz-executor244 Not tainted 6.0.0-rc1-next-20220819-syzkaller #0
BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1521
in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 3609, name: syz-executor244
preempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
INFO: lockdep is turned off.
irq event stamp: 186633
hardirqs last  enabled at (186633): [<ffffffff814f2b88>] __cancel_work_timer+0x408/0x570 kernel/workqueue.c:3153
hardirqs last disabled at (186632): [<ffffffff814f23ed>] try_to_grab_pending+0xbd/0xd0 kernel/workqueue.c:1264
softirqs last  enabled at (186628): [<ffffffff888702ae>] kcm_attach net/kcm/kcmsock.c:1427 [inline]
softirqs last  enabled at (186628): [<ffffffff888702ae>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
softirqs last  enabled at (186628): [<ffffffff888702ae>] kcm_ioctl+0x8fe/0x1180 net/kcm/kcmsock.c:1696
softirqs last disabled at (186626): [<ffffffff8887026f>] kcm_attach net/kcm/kcmsock.c:1421 [inline]
softirqs last disabled at (186626): [<ffffffff8887026f>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
softirqs last disabled at (186626): [<ffffffff8887026f>] kcm_ioctl+0x8bf/0x1180 net/kcm/kcmsock.c:1696
CPU: 0 PID: 3609 Comm: syz-executor244 Not tainted 6.0.0-rc1-next-20220819-syzkaller #0
syz-executor244[3609] cmdline: ./syz-executor2443547741
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:122 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:140
 __might_resched.cold+0x222/0x26b kernel/sched/core.c:9896
 down_read_killable+0x75/0x490 kernel/locking/rwsem.c:1521
 mmap_read_lock_killable include/linux/mmap_lock.h:126 [inline]
 __access_remote_vm+0xac/0x6f0 mm/memory.c:5461
 get_mm_cmdline.part.0+0x217/0x620 fs/proc/base.c:299
 get_mm_cmdline fs/proc/base.c:367 [inline]
 get_task_cmdline_kernel+0x1d9/0x220 fs/proc/base.c:367
 dump_stack_print_cmdline.part.0+0x82/0x150 lib/dump_stack.c:61
 dump_stack_print_cmdline lib/dump_stack.c:89 [inline]
 dump_stack_print_info+0x185/0x190 lib/dump_stack.c:97
 __dump_stack lib/dump_stack.c:121 [inline]
 dump_stack_lvl+0xc1/0x134 lib/dump_stack.c:140
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2175
 check_prev_add kernel/locking/lockdep.c:3095 [inline]
 check_prevs_add kernel/locking/lockdep.c:3214 [inline]
 validate_chain kernel/locking/lockdep.c:3829 [inline]
 __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
 lock_acquire kernel/locking/lockdep.c:5666 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
 __flush_work+0x105/0xae0 kernel/workqueue.c:3069
 __cancel_work_timer+0x3f9/0x570 kernel/workqueue.c:3160
 strp_done+0x64/0xf0 net/strparser/strparser.c:513
 kcm_attach net/kcm/kcmsock.c:1429 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
 kcm_ioctl+0x913/0x1180 net/kcm/kcmsock.c:1696
 sock_do_ioctl+0xcc/0x230 net/socket.c:1169
 sock_ioctl+0x2f1/0x640 net/socket.c:1286
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 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+0x63/0xcd
RIP: 0033:0x7f8cd11bfaf9
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:00007fff00d82a88 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fff00d82a98 RCX: 00007f8cd11bfaf9
RDX: 0000000020000180 RSI: 00000000000089e0 RDI: 0000000000000005
RBP: 0000000000000003 R08: bb1414ac00000000 R09: bb1414ac00000000
R10: bb1414ac00000000 R11: 0000000000000246 R12: 00007fff00d82aa0
R13: 00007fff00d82a94 R14: 0000000000000003 R15: 0000000000000000
 </TASK>
syz-executor244[3609] cmdline: ./syz-executor2443547741
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:122 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:140
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2175
 check_prev_add kernel/locking/lockdep.c:3095 [inline]
 check_prevs_add kernel/locking/lockdep.c:3214 [inline]
 validate_chain kernel/locking/lockdep.c:3829 [inline]
 __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
 lock_acquire kernel/locking/lockdep.c:5666 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
 __flush_work+0x105/0xae0 kernel/workqueue.c:3069
 __cancel_work_timer+0x3f9/0x570 kernel/workqueue.c:3160
 strp_done+0x64/0xf0 net/strparser/strparser.c:513
 kcm_attach net/kcm/kcmsock.c:1429 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
 kcm_ioctl+0x913/0x1180 net/kcm/kcmsock.c:1696
 sock_do_ioctl+0xcc/0x230 net/socket.c:1169
 sock_ioctl+0x2f1/0x640 net/socket.c:1286
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 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+0x63/0xcd
RIP: 0033:0x7f8cd11bfaf9
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:00007fff00d82a88 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fff00d82a98 RCX: 00007f8cd11bfaf9
RDX: 0000000020000180 RSI: 00000000000089e0 RDI: 0000000000000005
RBP: 0000000000000003 R08: bb1414ac00000000 R09: bb1414ac00000000
R10: bb1414ac00000000 R11: 0000000000000246 R12: 00007fff00d82aa0
R13: 00007fff00d82a94 R14: 0000000000000003 R15: 0000000000000000
 </TASK>

Crashes (20):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/08/22 07:45 linux-next 8755ae45a9e8 26a13b38 .config strace log report syz C ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/17 15:07 linux-next 95d10484d66e 4e72d229 .config strace log report syz C ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/17 14:11 linux-next 95d10484d66e 4e72d229 .config strace log report syz C ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/22 19:21 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/22 12:27 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/22 02:49 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/21 21:35 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/21 03:25 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/19 18:56 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/19 16:23 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/19 09:52 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/19 06:38 linux-next 8755ae45a9e8 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/19 01:12 linux-next 5b6a4bf680d6 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/18 21:17 linux-next 5b6a4bf680d6 26a13b38 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/18 12:16 linux-next 5b6a4bf680d6 d58e263f .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/18 11:10 linux-next 5b6a4bf680d6 d58e263f .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/18 09:51 linux-next 5b6a4bf680d6 d58e263f .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/18 03:34 linux-next 95d10484d66e d58e263f .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/18 01:13 linux-next 95d10484d66e d58e263f .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
2022/08/17 06:19 linux-next 95d10484d66e 4e72d229 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in kcm_ioctl
* Struck through repros no longer work on HEAD.