[v5.15] possible deadlock in virtual_nci_close

3 views
Skip to first unread message

syzbot

unread,
Mar 7, 2023, 11:11:43 AM3/7/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: d9b4a0c83a2d Linux 5.15.98
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=178a6f82c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=b57cfa804330c3b7
dashboard link: https://syzkaller.appspot.com/bug?extid=e45a68a6cb6ca1142e80
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8088989394e3/disk-d9b4a0c8.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2651d6753959/vmlinux-d9b4a0c8.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f3fa3f994f9a/Image-d9b4a0c8.gz.xz

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

nci: __nci_request: wait_for_completion_interruptible_timeout failed -512
======================================================
WARNING: possible circular locking dependency detected
5.15.98-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/5686 is trying to acquire lock:
ffff800015cd4fe8 (nci_mutex){+.+.}-{3:3}, at: virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44

but task is already holding lock:
ffff0000c62aa350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0xf0/0x5dc net/nfc/nci/core.c:560

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ndev->req_lock){+.+.}-{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
nci_request net/nfc/nci/core.c:148 [inline]
nci_set_local_general_bytes net/nfc/nci/core.c:774 [inline]
nci_start_poll+0x498/0x1204 net/nfc/nci/core.c:838
nfc_start_poll+0x164/0x2a4 net/nfc/core.c:225
nfc_genl_start_poll+0x1b8/0x308 net/nfc/netlink.c:828
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:2533
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+0x814/0xb00 net/netlink/af_netlink.c:1952
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 <unknown>:584

-> #2 (&genl_data->genl_data_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
nfc_urelease_event_work+0xfc/0x2a8 net/nfc/netlink.c:1819
process_one_work+0x82c/0x1478 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870

-> #1 (nfc_devlist_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
nfc_register_device+0x4c/0x310 net/nfc/core.c:1116
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:3480 [inline]
path_openat+0x1f00/0x26c4 fs/namei.c:3615
do_filp_open+0x1a8/0x3b4 fs/namei.c:3642
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 <unknown>:584

-> #0 (nci_mutex){+.+.}-{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+0x2b8/0x894 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
virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44
nci_close_device+0x304/0x5dc net/nfc/nci/core.c:592
nci_unregister_device+0x5c/0x22c net/nfc/nci/core.c:1295
virtual_ncidev_close+0x70/0xb0 drivers/nfc/virtual_ncidev.c:166
__fput+0x30c/0x7f0 fs/file_table.c:280
____fput+0x20/0x30 fs/file_table.c:308
task_work_run+0x130/0x1e4 kernel/task_work.c:164
get_signal+0x1450/0x1550 kernel/signal.c:2661
do_signal arch/arm64/kernel/signal.c:890 [inline]
do_notify_resume+0x3d0/0x32b8 arch/arm64/kernel/signal.c:943
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:597
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

other info that might help us debug this:

Chain exists of:
nci_mutex --> &genl_data->genl_data_mutex --> &ndev->req_lock

Possible unsafe locking scenario:

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

*** DEADLOCK ***

1 lock held by syz-executor.1/5686:
#0: ffff0000c62aa350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0xf0/0x5dc net/nfc/nci/core.c:560

stack backtrace:
CPU: 0 PID: 5686 Comm: syz-executor.1 Not tainted 5.15.98-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
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+0x2b8/0x894 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
virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44
nci_close_device+0x304/0x5dc net/nfc/nci/core.c:592
nci_unregister_device+0x5c/0x22c net/nfc/nci/core.c:1295
virtual_ncidev_close+0x70/0xb0 drivers/nfc/virtual_ncidev.c:166
__fput+0x30c/0x7f0 fs/file_table.c:280
____fput+0x20/0x30 fs/file_table.c:308
task_work_run+0x130/0x1e4 kernel/task_work.c:164
get_signal+0x1450/0x1550 kernel/signal.c:2661
do_signal arch/arm64/kernel/signal.c:890 [inline]
do_notify_resume+0x3d0/0x32b8 arch/arm64/kernel/signal.c:943
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:597
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584


---
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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Mar 7, 2023, 12:07:46 PM3/7/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 42616e0f09fb Linux 6.1.15
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16a8ef04c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=690b9ff41783cd73
dashboard link: https://syzkaller.appspot.com/bug?extid=f9c1c9ba849bff911be2
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/db869f2ed2bd/disk-42616e0f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/37951bbe5829/vmlinux-42616e0f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/23aa1a75ce0f/bzImage-42616e0f.xz

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

======================================================
WARNING: possible circular locking dependency detected
6.1.15-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/4187 is trying to acquire lock:
ffffffff8d7c4128 (nci_mutex){+.+.}-{3:3}, at: virtual_nci_close+0x13/0x40 drivers/nfc/virtual_ncidev.c:44

but task is already holding lock:
ffff8880587b9350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0x106/0x5f0 net/nfc/nci/core.c:560

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ndev->req_lock){+.+.}-{3:3}:
lock_acquire+0x231/0x620 kernel/locking/lockdep.c:5668
__mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
nci_request net/nfc/nci/core.c:148 [inline]
nci_set_local_general_bytes net/nfc/nci/core.c:774 [inline]
nci_start_poll+0x59f/0xf20 net/nfc/nci/core.c:838
nfc_start_poll+0x184/0x2f0 net/nfc/core.c:225
nfc_genl_start_poll+0x1e7/0x350 net/nfc/netlink.c:828
genl_family_rcv_msg_doit net/netlink/genetlink.c:756 [inline]
genl_family_rcv_msg net/netlink/genetlink.c:833 [inline]
genl_rcv_msg+0xc1a/0xf70 net/netlink/genetlink.c:850
netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2550
genl_rcv+0x24/0x40 net/netlink/genetlink.c:861
netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
netlink_sendmsg+0x9fe/0xd10 net/netlink/af_netlink.c:1931
sock_sendmsg_nosec net/socket.c:714 [inline]
sock_sendmsg net/socket.c:734 [inline]
____sys_sendmsg+0x59e/0x8f0 net/socket.c:2485
___sys_sendmsg net/socket.c:2539 [inline]
__sys_sendmsg+0x2a9/0x390 net/socket.c:2568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #2 (&genl_data->genl_data_mutex){+.+.}-{3:3}:
lock_acquire+0x231/0x620 kernel/locking/lockdep.c:5668
__mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
nfc_urelease_event_work+0x113/0x2f0 net/nfc/netlink.c:1835
process_one_work+0x8ee/0x1350 kernel/workqueue.c:2289
worker_thread+0xa5f/0x1210 kernel/workqueue.c:2436
kthread+0x268/0x300 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

-> #1 (nfc_devlist_mutex){+.+.}-{3:3}:
lock_acquire+0x231/0x620 kernel/locking/lockdep.c:5668
__mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
nfc_register_device+0x38/0x310 net/nfc/core.c:1116
nci_register_device+0x7be/0x900 net/nfc/nci/core.c:1256
virtual_ncidev_open+0x55/0xc0 drivers/nfc/virtual_ncidev.c:146
misc_open+0x304/0x380 drivers/char/misc.c:143
chrdev_open+0x54a/0x630 fs/char_dev.c:414
do_dentry_open+0x7f9/0x10f0 fs/open.c:882
do_open fs/namei.c:3557 [inline]
path_openat+0x263f/0x2e60 fs/namei.c:3714
do_filp_open+0x230/0x480 fs/namei.c:3741
do_sys_openat2+0x13b/0x500 fs/open.c:1310
do_sys_open fs/open.c:1326 [inline]
__do_sys_openat fs/open.c:1342 [inline]
__se_sys_openat fs/open.c:1337 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1337
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (nci_mutex){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3097 [inline]
check_prevs_add kernel/locking/lockdep.c:3216 [inline]
validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3831
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5055
lock_acquire+0x231/0x620 kernel/locking/lockdep.c:5668
__mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
virtual_nci_close+0x13/0x40 drivers/nfc/virtual_ncidev.c:44
nci_close_device+0x3a8/0x5f0 net/nfc/nci/core.c:592
nci_unregister_device+0x3c/0x230 net/nfc/nci/core.c:1291
virtual_ncidev_close+0x55/0x90 drivers/nfc/virtual_ncidev.c:166
__fput+0x3b7/0x890 fs/file_table.c:320
task_work_run+0x246/0x300 kernel/task_work.c:179
get_signal+0x15fc/0x17d0 kernel/signal.c:2635
arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:869
exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x60/0x2c0 kernel/entry/common.c:296
do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
nci_mutex --> &genl_data->genl_data_mutex --> &ndev->req_lock

Possible unsafe locking scenario:

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

*** DEADLOCK ***

1 lock held by syz-executor.4/4187:
#0: ffff8880587b9350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0x106/0x5f0 net/nfc/nci/core.c:560

stack backtrace:
CPU: 1 PID: 4187 Comm: syz-executor.4 Not tainted 6.1.15-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2177
check_prev_add kernel/locking/lockdep.c:3097 [inline]
check_prevs_add kernel/locking/lockdep.c:3216 [inline]
validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3831
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5055
lock_acquire+0x231/0x620 kernel/locking/lockdep.c:5668
__mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
virtual_nci_close+0x13/0x40 drivers/nfc/virtual_ncidev.c:44
nci_close_device+0x3a8/0x5f0 net/nfc/nci/core.c:592
nci_unregister_device+0x3c/0x230 net/nfc/nci/core.c:1291
virtual_ncidev_close+0x55/0x90 drivers/nfc/virtual_ncidev.c:166
__fput+0x3b7/0x890 fs/file_table.c:320
task_work_run+0x246/0x300 kernel/task_work.c:179
get_signal+0x15fc/0x17d0 kernel/signal.c:2635
arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:869
exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x60/0x2c0 kernel/entry/common.c:296
do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fed02a8c0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fed0370d168 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: fffffffffffffff2 RBX: 00007fed02babf80 RCX: 00007fed02a8c0f9
RDX: 0000000000000064 RSI: 0000000020000840 RDI: 0000000000000003
RBP: 00007fed02ae7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff58fd3d0f R14: 00007fed0370d300 R15: 0000000000022000
</TASK>

syzbot

unread,
Mar 8, 2023, 5:56:49 AM3/8/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: d9b4a0c83a2d Linux 5.15.98
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=14114754c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=b57cfa804330c3b7
dashboard link: https://syzkaller.appspot.com/bug?extid=e45a68a6cb6ca1142e80
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13aa92eac80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=179acdcac80000
nci: __nci_request: wait_for_completion_interruptible_timeout failed 0
======================================================
WARNING: possible circular locking dependency detected
5.15.98-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor667/4053 is trying to acquire lock:
ffff800015cd4fe8 (nci_mutex){+.+.}-{3:3}, at: virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44

but task is already holding lock:
ffff0000d01f9350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0xf0/0x5dc net/nfc/nci/core.c:560
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
do_notify_resume+0x262c/0x32b8 arch/arm64/kernel/signal.c:946
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:597
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

other info that might help us debug this:

Chain exists of:
nci_mutex --> &genl_data->genl_data_mutex --> &ndev->req_lock

Possible unsafe locking scenario:

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

*** DEADLOCK ***

1 lock held by syz-executor667/4053:
#0: ffff0000d01f9350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0xf0/0x5dc net/nfc/nci/core.c:560

stack backtrace:
CPU: 1 PID: 4053 Comm: syz-executor667 Not tainted 5.15.98-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
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+0x2b8/0x894 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
virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44
nci_close_device+0x304/0x5dc net/nfc/nci/core.c:592
nci_unregister_device+0x5c/0x22c net/nfc/nci/core.c:1295
virtual_ncidev_close+0x70/0xb0 drivers/nfc/virtual_ncidev.c:166
__fput+0x30c/0x7f0 fs/file_table.c:280
____fput+0x20/0x30 fs/file_table.c:308
task_work_run+0x130/0x1e4 kernel/task_work.c:164
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
do_notify_resume+0x262c/0x32b8 arch/arm64/kernel/signal.c:946

syzbot

unread,
Mar 9, 2023, 8:44:43 AM3/9/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 42616e0f09fb Linux 6.1.15
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1461b888c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=650737f7e9682672
dashboard link: https://syzkaller.appspot.com/bug?extid=f9c1c9ba849bff911be2
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15345146c80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161a067cc80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f10713d1fd0f/disk-42616e0f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5a1307bb774e/vmlinux-42616e0f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/388238a30fe4/Image-42616e0f.gz.xz

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

nci: __nci_request: wait_for_completion_interruptible_timeout failed 0
======================================================
WARNING: possible circular locking dependency detected
6.1.15-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor773/4324 is trying to acquire lock:
ffff800016d8c588 (nci_mutex){+.+.}-{3:3}, at: virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44

but task is already holding lock:
ffff0000d8131350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0xf0/0x5ac net/nfc/nci/core.c:560

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ndev->req_lock){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
nci_request net/nfc/nci/core.c:148 [inline]
nci_set_local_general_bytes net/nfc/nci/core.c:774 [inline]
nci_start_poll+0x498/0x1204 net/nfc/nci/core.c:838
nfc_start_poll+0x164/0x2a4 net/nfc/core.c:225
nfc_genl_start_poll+0x1b8/0x308 net/nfc/netlink.c:828
genl_family_rcv_msg_doit net/netlink/genetlink.c:756 [inline]
genl_family_rcv_msg net/netlink/genetlink.c:833 [inline]
genl_rcv_msg+0x948/0xc2c net/netlink/genetlink.c:850
netlink_rcv_skb+0x20c/0x3b8 net/netlink/af_netlink.c:2550
genl_rcv+0x38/0x50 net/netlink/genetlink.c:861
netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
netlink_unicast+0x660/0x8d4 net/netlink/af_netlink.c:1354
netlink_sendmsg+0x800/0xae0 net/netlink/af_netlink.c:1931
sock_sendmsg_nosec net/socket.c:714 [inline]
sock_sendmsg net/socket.c:734 [inline]
____sys_sendmsg+0x558/0x844 net/socket.c:2485
___sys_sendmsg net/socket.c:2539 [inline]
__sys_sendmsg+0x26c/0x33c net/socket.c:2568
__do_sys_sendmsg net/socket.c:2577 [inline]
__se_sys_sendmsg net/socket.c:2575 [inline]
__arm64_sys_sendmsg+0x80/0x94 net/socket.c:2575
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #2 (&genl_data->genl_data_mutex){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
nfc_urelease_event_work+0xfc/0x2a8 net/nfc/netlink.c:1835
process_one_work+0x848/0x16b4 kernel/workqueue.c:2289
worker_thread+0x8e4/0xfec kernel/workqueue.c:2436
kthread+0x24c/0x2d4 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

-> #1 (nfc_devlist_mutex){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
nfc_register_device+0x4c/0x310 net/nfc/core.c:1116
nci_register_device+0x6ac/0x7c4 net/nfc/nci/core.c:1256
virtual_ncidev_open+0x6c/0xd8 drivers/nfc/virtual_ncidev.c:146
misc_open+0x2f0/0x368 drivers/char/misc.c:143
chrdev_open+0x3e8/0x4fc fs/char_dev.c:414
do_dentry_open+0x734/0xfa0 fs/open.c:882
vfs_open+0x7c/0x90 fs/open.c:1013
do_open fs/namei.c:3557 [inline]
path_openat+0x1e10/0x2540 fs/namei.c:3714
do_filp_open+0x1bc/0x3cc fs/namei.c:3741
do_sys_openat2+0x128/0x3d8 fs/open.c:1310
do_sys_open fs/open.c:1326 [inline]
__do_sys_openat fs/open.c:1342 [inline]
__se_sys_openat fs/open.c:1337 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1337
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #0 (nci_mutex){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3097 [inline]
check_prevs_add kernel/locking/lockdep.c:3216 [inline]
validate_chain kernel/locking/lockdep.c:3831 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5055
lock_acquire+0x2f8/0x8dc kernel/locking/lockdep.c:5668
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44
nci_close_device+0x2fc/0x5ac net/nfc/nci/core.c:592
nci_unregister_device+0x58/0x21c net/nfc/nci/core.c:1291
virtual_ncidev_close+0x70/0xb0 drivers/nfc/virtual_ncidev.c:166
__fput+0x30c/0x7bc fs/file_table.c:320
____fput+0x20/0x30 fs/file_table.c:348
task_work_run+0x240/0x2f0 kernel/task_work.c:179
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0x538/0x1af8 kernel/exit.c:867
do_group_exit+0x194/0x22c kernel/exit.c:1012
get_signal+0x14a0/0x158c kernel/signal.c:2858
do_signal arch/arm64/kernel/signal.c:1076 [inline]
do_notify_resume+0x3ac/0x3470 arch/arm64/kernel/signal.c:1129
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

other info that might help us debug this:

Chain exists of:
nci_mutex --> &genl_data->genl_data_mutex --> &ndev->req_lock

Possible unsafe locking scenario:

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

*** DEADLOCK ***

1 lock held by syz-executor773/4324:
#0: ffff0000d8131350 (&ndev->req_lock){+.+.}-{3:3}, at: nci_close_device+0xf0/0x5ac net/nfc/nci/core.c:560

stack backtrace:
CPU: 1 PID: 4324 Comm: syz-executor773 Not tainted 6.1.15-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__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:2055
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2177
check_prev_add kernel/locking/lockdep.c:3097 [inline]
check_prevs_add kernel/locking/lockdep.c:3216 [inline]
validate_chain kernel/locking/lockdep.c:3831 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5055
lock_acquire+0x2f8/0x8dc kernel/locking/lockdep.c:5668
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
virtual_nci_close+0x28/0x58 drivers/nfc/virtual_ncidev.c:44
nci_close_device+0x2fc/0x5ac net/nfc/nci/core.c:592
nci_unregister_device+0x58/0x21c net/nfc/nci/core.c:1291
virtual_ncidev_close+0x70/0xb0 drivers/nfc/virtual_ncidev.c:166
__fput+0x30c/0x7bc fs/file_table.c:320
____fput+0x20/0x30 fs/file_table.c:348
task_work_run+0x240/0x2f0 kernel/task_work.c:179
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0x538/0x1af8 kernel/exit.c:867
do_group_exit+0x194/0x22c kernel/exit.c:1012
get_signal+0x14a0/0x158c kernel/signal.c:2858
do_signal arch/arm64/kernel/signal.c:1076 [inline]
do_notify_resume+0x3ac/0x3470 arch/arm64/kernel/signal.c:1129
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

syzbot

unread,
Nov 12, 2023, 9:21:09 PM11/12/23
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

commit b2e44aac91b25abbed57d785089c4b7af926a7bd
git tree: upstream
Author: Dmitry Vyukov <dvy...@google.com>
Date: Tue Nov 15 10:00:17 2022 +0000

NFC: nci: Allow to create multiple virtual nci devices

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=14e54b97680000
kernel config: https://syzkaller.appspot.com/x/.config?x=f749f501f45a424b
dashboard link: https://syzkaller.appspot.com/bug?extid=f9c1c9ba849bff911be2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11b91144280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1601d510280000


Please keep in mind that other backports might be required as well.

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Nov 17, 2023, 7:22:05 PM11/17/23
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

commit b2e44aac91b25abbed57d785089c4b7af926a7bd
git tree: upstream
Author: Dmitry Vyukov <dvy...@google.com>
Date: Tue Nov 15 10:00:17 2022 +0000

NFC: nci: Allow to create multiple virtual nci devices

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=156b4e48e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=ba8d5c9d6c5289f
dashboard link: https://syzkaller.appspot.com/bug?extid=e45a68a6cb6ca1142e80
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12a6be82280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=177ca3f4280000
Reply all
Reply to author
Forward
0 new messages