From: syzbot <syzbot+eaa925b668db275992c4@syzkaller.appspotmail.com>
To: dsterba@suse.com, josef@toxicpanda.com,
linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org, mason@kernel.org,
nbd@other.debian.org, syzkaller-bugs@googlegroups.com
Subject: [syzbot] [nbd?] possible deadlock in submit_bio_noacct_nocheck (3)
Date: Sat, 05 Dec 2026 07:50:39 -0800 [thread overview]
Message-ID: <6b1432cf.5bcce40b.3b9993.0085.GAE@google.com> (raw)
Hello,
syzbot found the following issue on:
HEAD commit: 28a23309c8e4 Merge tag 'for-7.4-rc5-tag' of git://git.kern..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=141f1553580000
kernel config: https://syzkaller.appspot.com/x/.config?x=d07b2352498f5906
dashboard link: https://syzkaller.appspot.com/bug?extid=eaa925b668db275992c4
compiler: Debian clang version 22.1.8 (1~deb13u5), Debian LLD 22.1.8
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16a39fbd580000
AI-generated root cause summary:
The NBD driver (drivers/block/nbd.c) accepts userspace socket file descriptors
via NBD_SET_SOCK, NBD_CMD_CONNECT, and NBD_CMD_RECONNECT (nbd_get_socket() /
nbd_add_socket()) and reclassifies them with nbd_reclassify_socket() into a
block-driver socket lock class (sk_lock-AF_INET-NBD), without preventing
userspace from continuing to perform socket syscalls on those retained file
descriptors. When userspace calls recv() on an NBD-reclassified socket with a
userspace buffer, tcp_recvmsg() acquires sk_lock above mm->mmap_lock (and via
vm_lock -> sb_pagefaults -> btrfs_page_mkwrite() above &ei->i_mmap_lock).
Meanwhile, filesystem operations such as btrfs_fallocate() hold &ei->i_mmap_lock
across block I/O submission/completion on the NBD device (&q->q_usage_counter ->
&q->elevator_lock -> set->srcu -> &cmd->lock -> sk_lock-AF_INET-NBD), forming a
circular locking dependency and allowing a real deadlock if socket I/O faults
onto a filesystem page backed by the same NBD device.
full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=eaa925b668db275992c4
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+eaa925b668db275992c4@syzkaller.appspotmail.com
BTRFS info (device nbd20): enabling ssd optimizations
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz-executor175/6021 is trying to acquire lock:
ffff88802be77020 (&q->q_usage_counter(io)#69){++++}-{0:0}, at: __submit_bio_noacct_mq block/blk-core.c:755 [inline]
ffff88802be77020 (&q->q_usage_counter(io)#69){++++}-{0:0}, at: submit_bio_noacct_nocheck+0x2fe/0xb80 block/blk-core.c:789
but task is already holding lock:
ffff888076f53d98 (&ei->i_mmap_lock){++++}-{4:4}, at: btrfs_inode_lock+0xcb/0xe0 fs/btrfs/inode.c:368
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #8 (&ei->i_mmap_lock){++++}-{4:4}:
down_read+0x45/0x320 kernel/locking/rwsem.c:1574
btrfs_page_mkwrite+0x607/0x1a30 fs/btrfs/file.c:1889
do_page_mkwrite+0x147/0x310 mm/memory.c:3908
do_shared_fault mm/memory.c:6215 [inline]
do_fault mm/memory.c:6277 [inline]
do_pte_missing+0x70f/0x3570 mm/memory.c:4800
handle_pte_fault mm/memory.c:6692 [inline]
__handle_mm_fault mm/memory.c:6844 [inline]
handle_mm_fault+0x1807/0x2f80 mm/memory.c:7011
do_user_addr_fault+0xb35/0x1480 arch/x86/mm/fault.c:1343
handle_page_fault arch/x86/mm/fault.c:1483 [inline]
exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1536
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
-> #7 (sb_pagefaults#2){.+.+}-{0:0}:
percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline]
percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline]
__sb_start_write include/linux/fs/super.h:19 [inline]
sb_start_pagefault include/linux/fs/super.h:159 [inline]
btrfs_page_mkwrite+0x2fe/0x1a30 fs/btrfs/file.c:1844
do_page_mkwrite+0x147/0x310 mm/memory.c:3908
do_shared_fault mm/memory.c:6215 [inline]
do_fault mm/memory.c:6277 [inline]
do_pte_missing+0x70f/0x3570 mm/memory.c:4800
handle_pte_fault mm/memory.c:6692 [inline]
__handle_mm_fault mm/memory.c:6844 [inline]
handle_mm_fault+0x1807/0x2f80 mm/memory.c:7011
do_user_addr_fault+0xb35/0x1480 arch/x86/mm/fault.c:1343
handle_page_fault arch/x86/mm/fault.c:1483 [inline]
exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1536
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
-> #6 (vm_lock){++++}-{0:0}:
__vma_start_exclude_readers+0x283/0x9b0 mm/mmap_lock.c:124
__vma_start_write+0xdc/0x290 mm/mmap_lock.c:147
vma_start_write include/linux/mmap_lock.h:324 [inline]
mprotect_fixup+0x6b2/0xf20 mm/mprotect.c:835
setup_arg_pages+0x653/0xbe0 fs/exec.c:675
load_elf_binary+0xc6c/0x28d0 fs/binfmt_elf.c:1028
search_binary_handler fs/exec.c:1777 [inline]
exec_binprm fs/exec.c:1809 [inline]
bprm_execve+0x930/0x1590 fs/exec.c:1865
kernel_execve+0x8af/0x9a0 fs/exec.c:2009
try_to_run_init_process+0x13/0x60 init/main.c:1561
kernel_init+0xb2/0x1d0 init/main.c:1691
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
-> #5 (&mm->mmap_lock){++++}-{4:4}:
__might_fault+0xcb/0x130 mm/memory.c:7602
_copy_to_iter+0xf9/0x17e0 lib/iov_iter.c:196
copy_to_iter include/linux/uio.h:228 [inline]
simple_copy_to_iter net/core/datagram.c:521 [inline]
__skb_datagram_iter+0x419/0x980 net/core/datagram.c:435
skb_copy_datagram_iter+0xb5/0x240 net/core/datagram.c:535
skb_copy_datagram_msg include/linux/skbuff.h:4270 [inline]
tcp_recvmsg_locked+0xf4d/0x3870 net/ipv4/tcp.c:2853
tcp_recvmsg+0x206/0x850 net/ipv4/tcp.c:2957
sock_recvmsg_nosec net/socket.c:1156 [inline]
sock_recvmsg+0x166/0x1e0 net/socket.c:1176
__sys_recvfrom+0x231/0x3a0 net/socket.c:2333
__do_sys_recvfrom net/socket.c:2348 [inline]
__se_sys_recvfrom net/socket.c:2344 [inline]
__x64_sys_recvfrom+0xde/0x100 net/socket.c:2344
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
-> #4 (sk_lock-AF_INET-NBD){+.+.}-{0:0}:
lock_sock_nested+0x41/0x100 net/core/sock.c:3914
lock_sock include/net/sock.h:1717 [inline]
tcp_recvmsg+0x1e1/0x850 net/ipv4/tcp.c:2956
sock_recvmsg_nosec net/socket.c:1156 [inline]
sock_recvmsg+0x166/0x1e0 net/socket.c:1176
__sock_xmit+0x24f/0x510 drivers/block/nbd.c:587
sock_xmit drivers/block/nbd.c:614 [inline]
nbd_handle_reply drivers/block/nbd.c:952 [inline]
recv_work+0xbdf/0x1e30 drivers/block/nbd.c:1009
process_one_work kernel/workqueue.c:3507 [inline]
process_scheduled_works+0xc5d/0x1650 kernel/workqueue.c:3590
worker_thread+0xa47/0xfb0 kernel/workqueue.c:3671
kthread+0x38b/0x480 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
-> #3 (&cmd->lock){+.+.}-{4:4}:
__mutex_lock_common kernel/locking/mutex.c:646 [inline]
__mutex_lock+0x197/0x15a0 kernel/locking/mutex.c:821
nbd_queue_rq+0xc1/0xff0 drivers/block/nbd.c:1199
blk_mq_dispatch_rq_list+0x499/0x1990 block/blk-mq.c:2141
__blk_mq_do_dispatch_sched block/blk-mq-sched.c:168 [inline]
blk_mq_do_dispatch_sched block/blk-mq-sched.c:182 [inline]
__blk_mq_sched_dispatch_requests+0xd36/0x1580 block/blk-mq-sched.c:307
blk_mq_sched_dispatch_requests+0xd7/0x190 block/blk-mq-sched.c:329
blk_mq_run_work_fn+0x167/0x2f0 block/blk-mq.c:2556
process_one_work kernel/workqueue.c:3507 [inline]
process_scheduled_works+0xc5d/0x1650 kernel/workqueue.c:3590
worker_thread+0xa47/0xfb0 kernel/workqueue.c:3671
kthread+0x38b/0x480 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
-> #2 (set->srcu){.+.+}-{0:0}:
srcu_lock_sync include/linux/srcu.h:261 [inline]
__synchronize_srcu+0xca/0x2f0 kernel/rcu/srcutree.c:1662
elevator_switch+0x1e8/0x7b0 block/elevator.c:576
elevator_change+0x2fa/0x480 block/elevator.c:681
elevator_set_default+0x375/0x440 block/elevator.c:754
blk_register_queue+0x404/0x4f0 block/blk-sysfs.c:992
__add_disk+0x6b8/0xdb0 block/genhd.c:531
add_disk_fwnode+0x100/0x3a0 block/genhd.c:600
add_disk include/linux/blkdev.h:799 [inline]
nbd_dev_add+0x733/0xb60 drivers/block/nbd.c:2027
nbd_init+0x168/0x1f0 drivers/block/nbd.c:2744
do_one_initcall+0x250/0x870 init/main.c:1432
do_initcall_level+0x10a/0x1a0 init/main.c:1494
do_initcalls+0x59/0xa0 init/main.c:1510
kernel_init_freeable+0x29d/0x3e0 init/main.c:1745
kernel_init+0x22/0x1d0 init/main.c:1635
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
-> #1 (&q->elevator_lock){+.+.}-{4:4}:
__mutex_lock_common kernel/locking/mutex.c:646 [inline]
__mutex_lock+0x197/0x15a0 kernel/locking/mutex.c:821
elevator_change+0x1af/0x480 block/elevator.c:679
elv_iosched_store+0x50e/0x630 block/elevator.c:831
queue_attr_store+0x207/0x2b0 block/blk-sysfs.c:906
kernfs_fop_write_iter+0x3a4/0x540 fs/kernfs/file.c:345
new_sync_write fs/read_write.c:575 [inline]
vfs_write+0x612/0xba0 fs/read_write.c:667
ksys_write+0x150/0x270 fs/read_write.c:719
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
-> #0 (&q->q_usage_counter(io)#69){++++}-{0:0}:
check_prev_add kernel/locking/lockdep.c:3209 [inline]
check_prevs_add kernel/locking/lockdep.c:3328 [inline]
validate_chain kernel/locking/lockdep.c:3952 [inline]
__lock_acquire+0x164c/0x2de0 kernel/locking/lockdep.c:5288
lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
bio_queue_enter block/blk.h:95 [inline]
blk_mq_submit_bio+0x7c6/0x2eb0 block/blk-mq.c:3149
__submit_bio_noacct_mq block/blk-core.c:755 [inline]
submit_bio_noacct_nocheck+0x2fe/0xb80 block/blk-core.c:789
btrfs_submit_chunk fs/btrfs/bio.c:823 [inline]
btrfs_submit_bbio+0x132d/0x1ee0 fs/btrfs/bio.c:882
submit_one_bio+0x305/0x410 fs/btrfs/extent_io.c:193
submit_one_block+0xbe7/0xfa0 fs/btrfs/extent_io.c:-1
submit_write_sector fs/btrfs/extent_io.c:1882 [inline]
extent_writepage_io+0xcc1/0x1870 fs/btrfs/extent_io.c:1977
extent_writepage fs/btrfs/extent_io.c:2087 [inline]
extent_write_cache_pages fs/btrfs/extent_io.c:2834 [inline]
btrfs_writepages+0x1719/0x2830 fs/btrfs/extent_io.c:2965
do_writepages+0x338/0x560 mm/page-writeback.c:2562
filemap_writeback mm/filemap.c:386 [inline]
filemap_fdatawrite_range+0x1ef/0x2f0 mm/filemap.c:411
btrfs_fdatawrite_range+0x54/0xf0 fs/btrfs/file.c:3872
btrfs_wait_ordered_range+0x59/0x260 fs/btrfs/ordered-data.c:910
btrfs_fallocate+0xbc8/0x1df0 fs/btrfs/file.c:3162
vfs_fallocate+0x65a/0x7e0 fs/open.c:338
ksys_fallocate fs/open.c:362 [inline]
__do_sys_fallocate fs/open.c:367 [inline]
__se_sys_fallocate fs/open.c:365 [inline]
__x64_sys_fallocate+0xbf/0x110 fs/open.c:365
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
other info that might help us debug this:
Chain exists of:
&q->q_usage_counter(io)#69 --> sb_pagefaults#2 --> &ei->i_mmap_lock
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&ei->i_mmap_lock);
lock(sb_pagefaults#2);
lock(&ei->i_mmap_lock);
rlock(&q->q_usage_counter(io)#69);
*** DEADLOCK ***
locks held by syz-executor175/6021: 3, on CPU#0:
#0: ffff88802337c478 (sb_writers#12){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2765 [inline]
#0: ffff88802337c478 (sb_writers#12){.+.+}-{0:0}, at: vfs_fallocate+0x5e0/0x7e0 fs/open.c:337
#1: ffff888076f53f00 (&sb->s_type->i_mutex_key#24){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:1027 [inline]
#1: ffff888076f53f00 (&sb->s_type->i_mutex_key#24){+.+.}-{4:4}, at: btrfs_inode_lock+0x51/0xe0 fs/btrfs/inode.c:365
#2: ffff888076f53d98 (&ei->i_mmap_lock){++++}-{4:4}, at: btrfs_inode_lock+0xcb/0xe0 fs/btrfs/inode.c:368
stack backtrace:
CPU: 0 UID: 0 PID: 6021 Comm: syz-executor175 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_circular_bug+0x2e2/0x300 kernel/locking/lockdep.c:2087
check_noncircular+0x12f/0x150 kernel/locking/lockdep.c:2219
check_prev_add kernel/locking/lockdep.c:3209 [inline]
check_prevs_add kernel/locking/lockdep.c:3328 [inline]
validate_chain kernel/locking/lockdep.c:3952 [inline]
__lock_acquire+0x164c/0x2de0 kernel/locking/lockdep.c:5288
lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
bio_queue_enter block/blk.h:95 [inline]
blk_mq_submit_bio+0x7c6/0x2eb0 block/blk-mq.c:3149
__submit_bio_noacct_mq block/blk-core.c:755 [inline]
submit_bio_noacct_nocheck+0x2fe/0xb80 block/blk-core.c:789
btrfs_submit_chunk fs/btrfs/bio.c:823 [inline]
btrfs_submit_bbio+0x132d/0x1ee0 fs/btrfs/bio.c:882
submit_one_bio+0x305/0x410 fs/btrfs/extent_io.c:193
submit_one_block+0xbe7/0xfa0 fs/btrfs/extent_io.c:-1
submit_write_sector fs/btrfs/extent_io.c:1882 [inline]
extent_writepage_io+0xcc1/0x1870 fs/btrfs/extent_io.c:1977
extent_writepage fs/btrfs/extent_io.c:2087 [inline]
extent_write_cache_pages fs/btrfs/extent_io.c:2834 [inline]
btrfs_writepages+0x1719/0x2830 fs/btrfs/extent_io.c:2965
do_writepages+0x338/0x560 mm/page-writeback.c:2562
filemap_writeback mm/filemap.c:386 [inline]
filemap_fdatawrite_range+0x1ef/0x2f0 mm/filemap.c:411
btrfs_fdatawrite_range+0x54/0xf0 fs/btrfs/file.c:3872
btrfs_wait_ordered_range+0x59/0x260 fs/btrfs/ordered-data.c:910
btrfs_fallocate+0xbc8/0x1df0 fs/btrfs/file.c:3162
vfs_fallocate+0x65a/0x7e0 fs/open.c:338
ksys_fallocate fs/open.c:362 [inline]
__do_sys_fallocate fs/open.c:367 [inline]
__se_sys_fallocate fs/open.c:365 [inline]
__x64_sys_fallocate+0xbf/0x110 fs/open.c:365
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f0aeb035a1e
Code: 08 0f 85 f5 e2 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 90 41 57 41 56 4d 89 c6 41 55 4d 89 cd 41 54 55 53 48 83 ec 08
RSP: 002b:00007ffcd9377818 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 0000555572be0400 RCX: 00007f0aeb035a1e
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f0ae6e00000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000001000 R11: 0000000000000246 R12: 00007f0aeafc3000
R13: 0000000000000028 R14: 0000000000000028 R15: 00007ffcd9377ad0
</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@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
reply other threads:[~2026-12-05 15:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6b1432cf.5bcce40b.3b9993.0085.GAE@google.com \
--to=syzbot+eaa925b668db275992c4@syzkaller.appspotmail.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=nbd@other.debian.org \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox