syzbot


possible deadlock in nci_close_device

Status: auto-obsoleted due to no activity on 2024/01/16 04:06
Reported-by: syzbot+8b8e5aaba76d9aaafd02@syzkaller.appspotmail.com
First crash: 410d, last: 410d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in nci_close_device 1 232d 232d 0/3 auto-obsoleted due to no activity on 2024/07/12 04:08
upstream possible deadlock in nci_close_device net nfc 2 716d 730d 22/28 fixed on 2023/02/24 13:50

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.134-syzkaller #0 Not tainted
------------------------------------------------------
kworker/1:10/6485 is trying to acquire lock:
ffff0000d4bd7350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0xf0/0x5dc net/nfc/nci/core.c:560

but task is already holding lock:
ffff800016c6c9c8 (rfkill_global_mutex){+.+.}-{3:3}, at: rfkill_sync_work+0x34/0x104 net/rfkill/core.c:1028

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (rfkill_global_mutex){+.+.}-{3:3}:
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       rfkill_register+0x44/0x7a4 net/rfkill/core.c:1045
       nfc_register_device+0x148/0x310 net/nfc/core.c:1132
       nci_register_device+0x6ac/0x7c4 net/nfc/nci/core.c:1260
       virtual_ncidev_open+0x6c/0xd8 drivers/nfc/virtual_ncidev.c:146
       misc_open+0x2f0/0x368 drivers/char/misc.c:141
       chrdev_open+0x3e8/0x4fc fs/char_dev.c:414
       do_dentry_open+0x780/0xed8 fs/open.c:826
       vfs_open+0x7c/0x90 fs/open.c:956
       do_open fs/namei.c:3538 [inline]
       path_openat+0x1f28/0x26f0 fs/namei.c:3672
       do_filp_open+0x1a8/0x3b4 fs/namei.c:3699
       do_sys_openat2+0x128/0x3d8 fs/open.c:1211
       do_sys_open fs/open.c:1227 [inline]
       __do_sys_openat fs/open.c:1243 [inline]
       __se_sys_openat fs/open.c:1238 [inline]
       __arm64_sys_openat+0x1f0/0x240 fs/open.c:1238
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #1 (nci_mutex){+.+.}-{3:3}:
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44
       nci_open_device net/nfc/nci/core.c:544 [inline]
       nci_dev_up+0x760/0xb50 net/nfc/nci/core.c:631
       nfc_dev_up+0x154/0x300 net/nfc/core.c:118
       nfc_genl_dev_up+0x98/0xdc net/nfc/netlink.c:770
       genl_family_rcv_msg_doit net/netlink/genetlink.c:731 [inline]
       genl_family_rcv_msg net/netlink/genetlink.c:775 [inline]
       genl_rcv_msg+0xc18/0x1018 net/netlink/genetlink.c:792
       netlink_rcv_skb+0x20c/0x3b8 net/netlink/af_netlink.c:2505
       genl_rcv+0x38/0x50 net/netlink/genetlink.c:803
       netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
       netlink_unicast+0x664/0x938 net/netlink/af_netlink.c:1356
       netlink_sendmsg+0x844/0xb38 net/netlink/af_netlink.c:1924
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg net/socket.c:724 [inline]
       ____sys_sendmsg+0x584/0x870 net/socket.c:2412
       ___sys_sendmsg+0x214/0x294 net/socket.c:2466
       __sys_sendmsg net/socket.c:2495 [inline]
       __do_sys_sendmsg net/socket.c:2504 [inline]
       __se_sys_sendmsg net/socket.c:2502 [inline]
       __arm64_sys_sendmsg+0x1ac/0x25c net/socket.c:2502
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&ndev->req_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3787 [inline]
       __lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
       lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       nci_close_device+0xf0/0x5dc net/nfc/nci/core.c:560
       nci_dev_down+0x40/0x54 net/nfc/nci/core.c:638
       nfc_dev_down net/nfc/core.c:161 [inline]
       nfc_rfkill_set_block+0x14c/0x2d0 net/nfc/core.c:179
       rfkill_set_block+0x18c/0x37c net/rfkill/core.c:345
       rfkill_sync_work+0x98/0x104 net/rfkill/core.c:1030
       process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
       worker_thread+0x910/0x1034 kernel/workqueue.c:2457
       kthread+0x37c/0x45c kernel/kthread.c:319
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

other info that might help us debug this:

Chain exists of:
  &ndev->req_lock --> nci_mutex --> rfkill_global_mutex

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(rfkill_global_mutex);
                               lock(nci_mutex);
                               lock(rfkill_global_mutex);
  lock(&ndev->req_lock);

 *** DEADLOCK ***

4 locks held by kworker/1:10/6485:
 #0: ffff0000c0020d38 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x66c/0x11b8 kernel/workqueue.c:2283
 #1: ffff80001f157c00 ((work_completion)(&rfkill->sync_work)){+.+.}-{0:0}, at: process_one_work+0x6ac/0x11b8 kernel/workqueue.c:2285
 #2: ffff800016c6c9c8 (rfkill_global_mutex){+.+.}-{3:3}, at: rfkill_sync_work+0x34/0x104 net/rfkill/core.c:1028
 #3: ffff0000d4bd6190 (&dev->mutex){....}-{3:3}, at: device_lock include/linux/device.h:760 [inline]
 #3: ffff0000d4bd6190 (&dev->mutex){....}-{3:3}, at: nfc_dev_down net/nfc/core.c:143 [inline]
 #3: ffff0000d4bd6190 (&dev->mutex){....}-{3:3}, at: nfc_rfkill_set_block+0x50/0x2d0 net/nfc/core.c:179

stack backtrace:
CPU: 1 PID: 6485 Comm: kworker/1:10 Not tainted 5.15.134-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Workqueue: events rfkill_sync_work
Call trace:
 dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain kernel/locking/lockdep.c:3787 [inline]
 __lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
 __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
 nci_close_device+0xf0/0x5dc net/nfc/nci/core.c:560
 nci_dev_down+0x40/0x54 net/nfc/nci/core.c:638
 nfc_dev_down net/nfc/core.c:161 [inline]
 nfc_rfkill_set_block+0x14c/0x2d0 net/nfc/core.c:179
 rfkill_set_block+0x18c/0x37c net/rfkill/core.c:345
 rfkill_sync_work+0x98/0x104 net/rfkill/core.c:1030
 process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
 worker_thread+0x910/0x1034 kernel/workqueue.c:2457
 kthread+0x37c/0x45c kernel/kthread.c:319
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/08 04:05 linux-5.15.y 1edcec18cfb7 5e837c76 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in nci_close_device
* Struck through repros no longer work on HEAD.