====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Tainted: G L ------------------------------------------------------ syz.0.1970/12965 is trying to acquire lock: ffff888056f4c4a0 (btrfs-tree-01){++++}-{4:4}, at: btrfs_tree_read_lock_nested+0x45/0x250 fs/btrfs/locking.c:146 but task is already holding lock: ffff888052ec3d98 (&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: -> #10 (&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 wp_page_shared mm/memory.c:4317 [inline] do_wp_page+0x1a7c/0x4c40 mm/memory.c:4540 handle_pte_fault mm/memory.c:6724 [inline] __handle_mm_fault mm/memory.c:6849 [inline] handle_mm_fault+0x19c9/0x2f80 mm/memory.c:7016 do_user_addr_fault+0x7f6/0x1480 arch/x86/mm/fault.c:1394 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 copy_user_generic arch/x86/include/asm/uaccess_64.h:126 [inline] raw_copy_to_user arch/x86/include/asm/uaccess_64.h:147 [inline] _inline_copy_to_user include/linux/uaccess.h:202 [inline] _copy_to_user+0x85/0xb0 lib/usercopy.c:24 copy_to_user include/linux/uaccess.h:230 [inline] rng_dev_read+0x3ee/0x830 drivers/char/hw_random/core.c:287 vfs_read+0x213/0xa80 fs/read_write.c:552 ksys_read+0x150/0x270 fs/read_write.c:696 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 -> #9 (sb_pagefaults#4){++++}-{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 wp_page_shared mm/memory.c:4317 [inline] do_wp_page+0x1a7c/0x4c40 mm/memory.c:4540 handle_pte_fault mm/memory.c:6724 [inline] __handle_mm_fault mm/memory.c:6849 [inline] handle_mm_fault+0x19c9/0x2f80 mm/memory.c:7016 do_user_addr_fault+0x7f6/0x1480 arch/x86/mm/fault.c:1394 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 copy_user_generic arch/x86/include/asm/uaccess_64.h:126 [inline] raw_copy_to_user arch/x86/include/asm/uaccess_64.h:147 [inline] _inline_copy_to_user include/linux/uaccess.h:202 [inline] _copy_to_user+0x85/0xb0 lib/usercopy.c:24 copy_to_user include/linux/uaccess.h:230 [inline] rng_dev_read+0x3ee/0x830 drivers/char/hw_random/core.c:287 vfs_read+0x213/0xa80 fs/read_write.c:552 ksys_read+0x150/0x270 fs/read_write.c:696 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 -> #8 (&mm->mmap_lock){++++}-{4:4}: __might_fault+0xcb/0x130 mm/memory.c:7607 _copy_from_iter+0x100/0x1680 lib/iov_iter.c:271 copy_from_iter include/linux/uio.h:236 [inline] copy_from_iter_full include/linux/uio.h:253 [inline] skb_do_copy_data_nocache include/net/sock.h:2345 [inline] skb_copy_to_page_nocache include/net/sock.h:2371 [inline] tcp_sendmsg_locked+0x244e/0x57c0 net/ipv4/tcp.c:1324 tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1467 sock_sendmsg_nosec+0x10f/0x190 net/socket.c:801 __sock_sendmsg net/socket.c:818 [inline] sock_write_iter+0x2de/0x3e0 net/socket.c:1269 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 -> #7 (sk_lock-AF_INET){+.+.}-{0:0}: lock_sock_nested+0x41/0x100 net/core/sock.c:3909 lock_sock include/net/sock.h:1717 [inline] inet_shutdown+0x6a/0x390 net/ipv4/af_inet.c:913 nbd_mark_nsock_dead+0x2cb/0x550 drivers/block/nbd.c:319 recv_work+0x1d14/0x1e30 drivers/block/nbd.c:1030 process_one_work kernel/workqueue.c:3497 [inline] process_scheduled_works+0xc5d/0x1650 kernel/workqueue.c:3580 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3661 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 -> #6 (&nsock->tx_lock){+.+.}-{4:4}: __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x197/0x15a0 kernel/locking/mutex.c:821 nbd_handle_cmd drivers/block/nbd.c:1143 [inline] nbd_queue_rq+0x373/0xff0 drivers/block/nbd.c:1207 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:3497 [inline] process_scheduled_works+0xc5d/0x1650 kernel/workqueue.c:3580 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3661 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 -> #5 (&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:3497 [inline] process_scheduled_works+0xc5d/0x1650 kernel/workqueue.c:3580 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3661 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 -> #4 (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 -> #3 (&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 -> #2 (&q->q_usage_counter(io)#17){++++}-{0:0}: 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 read_extent_buffer_pages_nowait+0x747/0x860 fs/btrfs/extent_io.c:4381 read_extent_buffer_pages+0x22/0x100 fs/btrfs/extent_io.c:4390 btrfs_read_extent_buffer+0x9d/0x730 fs/btrfs/disk-io.c:236 read_block_for_search+0x67e/0xa40 fs/btrfs/ctree.c:1569 btrfs_search_slot+0x147a/0x2d20 fs/btrfs/ctree.c:2198 btrfs_init_root_free_objectid+0xf5/0x290 fs/btrfs/disk-io.c:5058 btrfs_init_fs_root+0x204/0x3b0 fs/btrfs/disk-io.c:1114 btrfs_get_root_ref+0x3c8/0x890 fs/btrfs/disk-io.c:1365 btrfs_get_fs_root fs/btrfs/disk-io.c:1417 [inline] open_ctree+0x2d07/0x4140 fs/btrfs/disk-io.c:3805 btrfs_fill_super fs/btrfs/super.c:971 [inline] btrfs_get_tree_super fs/btrfs/super.c:1956 [inline] btrfs_get_tree_subvol fs/btrfs/super.c:2099 [inline] btrfs_get_tree+0x10cf/0x1a00 fs/btrfs/super.c:2133 vfs_get_tree+0x92/0x2a0 fs/super.c:1881 fc_mount fs/namespace.c:1282 [inline] do_new_mount_fc fs/namespace.c:3910 [inline] do_new_mount+0x325/0xb00 fs/namespace.c:3986 do_mount fs/namespace.c:4350 [inline] __do_sys_mount fs/namespace.c:4563 [inline] __se_sys_mount+0x31d/0x420 fs/namespace.c:4540 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 -> #1 (btrfs-tree-00){++++}-{4:4}: down_read_nested+0x47/0x320 kernel/locking/rwsem.c:1709 btrfs_tree_read_lock_nested+0x45/0x250 fs/btrfs/locking.c:146 btrfs_tree_read_lock fs/btrfs/locking.h:188 [inline] read_block_for_search+0x617/0xa40 fs/btrfs/ctree.c:1563 btrfs_search_slot+0x147a/0x2d20 fs/btrfs/ctree.c:2198 btrfs_init_root_free_objectid+0xf5/0x290 fs/btrfs/disk-io.c:5058 btrfs_init_fs_root+0x204/0x3b0 fs/btrfs/disk-io.c:1114 btrfs_get_root_ref+0x3c8/0x890 fs/btrfs/disk-io.c:1365 btrfs_get_fs_root fs/btrfs/disk-io.c:1417 [inline] open_ctree+0x2d07/0x4140 fs/btrfs/disk-io.c:3805 btrfs_fill_super fs/btrfs/super.c:971 [inline] btrfs_get_tree_super fs/btrfs/super.c:1956 [inline] btrfs_get_tree_subvol fs/btrfs/super.c:2099 [inline] btrfs_get_tree+0x10cf/0x1a00 fs/btrfs/super.c:2133 vfs_get_tree+0x92/0x2a0 fs/super.c:1881 fc_mount fs/namespace.c:1282 [inline] do_new_mount_fc fs/namespace.c:3910 [inline] do_new_mount+0x325/0xb00 fs/namespace.c:3986 do_mount fs/namespace.c:4350 [inline] __do_sys_mount fs/namespace.c:4563 [inline] __se_sys_mount+0x31d/0x420 fs/namespace.c:4540 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 (btrfs-tree-01){++++}-{4:4}: 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 down_read_nested+0x47/0x320 kernel/locking/rwsem.c:1709 btrfs_tree_read_lock_nested+0x45/0x250 fs/btrfs/locking.c:146 btrfs_tree_read_lock fs/btrfs/locking.h:188 [inline] btrfs_read_lock_root_node+0x3f/0xd0 fs/btrfs/locking.c:267 btrfs_search_slot_get_root fs/btrfs/ctree.c:1740 [inline] btrfs_search_slot+0x66c/0x2d20 fs/btrfs/ctree.c:2070 btrfs_lookup_match_dir fs/btrfs/dir-item.c:196 [inline] btrfs_lookup_xattr+0xff/0x1e0 fs/btrfs/dir-item.c:369 btrfs_getxattr+0x97/0x1b0 fs/btrfs/xattr.c:41 btrfs_xattr_handler_get_security+0xd0/0x130 fs/btrfs/xattr.c:398 __vfs_getxattr+0x412/0x440 fs/xattr.c:446 cap_inode_need_killpriv+0x45/0x60 security/commoncap.c:331 security_inode_need_killpriv+0x85/0x240 security/security.c:2209 dentry_needs_remove_privs fs/inode.c:2372 [inline] file_remove_privs_flags+0x277/0x610 fs/inode.c:2403 file_modified_flags fs/inode.c:2552 [inline] file_modified+0x18/0x50 fs/inode.c:2571 btrfs_fallocate+0x79a/0x1df0 fs/btrfs/file.c:3126 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: btrfs-tree-01 --> sb_pagefaults#4 --> &ei->i_mmap_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&ei->i_mmap_lock); lock(sb_pagefaults#4); lock(&ei->i_mmap_lock); rlock(btrfs-tree-01); *** DEADLOCK *** locks held by syz.0.1970/12965: 3, on CPU#0: #0: ffff88805558c478 (sb_writers#12){++++}-{0:0}, at: file_start_write include/linux/fs.h:2765 [inline] #0: ffff88805558c478 (sb_writers#12){++++}-{0:0}, at: vfs_fallocate+0x5e0/0x7e0 fs/open.c:337 #1: ffff888052ec3f00 (&sb->s_type->i_mutex_key#24){++++}-{4:4}, at: inode_lock include/linux/fs.h:1027 [inline] #1: ffff888052ec3f00 (&sb->s_type->i_mutex_key#24){++++}-{4:4}, at: btrfs_inode_lock+0x51/0xe0 fs/btrfs/inode.c:365 #2: ffff888052ec3d98 (&ei->i_mmap_lock){++++}-{4:4}, at: btrfs_inode_lock+0xcb/0xe0 fs/btrfs/inode.c:368 stack backtrace: CPU: 0 UID: 0 PID: 12965 Comm: syz.0.1970 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026 Call Trace: 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 down_read_nested+0x47/0x320 kernel/locking/rwsem.c:1709 btrfs_tree_read_lock_nested+0x45/0x250 fs/btrfs/locking.c:146 btrfs_tree_read_lock fs/btrfs/locking.h:188 [inline] btrfs_read_lock_root_node+0x3f/0xd0 fs/btrfs/locking.c:267 btrfs_search_slot_get_root fs/btrfs/ctree.c:1740 [inline] btrfs_search_slot+0x66c/0x2d20 fs/btrfs/ctree.c:2070 btrfs_lookup_match_dir fs/btrfs/dir-item.c:196 [inline] btrfs_lookup_xattr+0xff/0x1e0 fs/btrfs/dir-item.c:369 btrfs_getxattr+0x97/0x1b0 fs/btrfs/xattr.c:41 btrfs_xattr_handler_get_security+0xd0/0x130 fs/btrfs/xattr.c:398 __vfs_getxattr+0x412/0x440 fs/xattr.c:446 cap_inode_need_killpriv+0x45/0x60 security/commoncap.c:331 security_inode_need_killpriv+0x85/0x240 security/security.c:2209 dentry_needs_remove_privs fs/inode.c:2372 [inline] file_remove_privs_flags+0x277/0x610 fs/inode.c:2403 file_modified_flags fs/inode.c:2552 [inline] file_modified+0x18/0x50 fs/inode.c:2571 btrfs_fallocate+0x79a/0x1df0 fs/btrfs/file.c:3126 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:0x7f81335a9c99 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 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 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f81344d8028 EFLAGS: 00000246 ORIG_RAX: 000000000000011d RAX: ffffffffffffffda RBX: 00007f8133835fa0 RCX: 00007f81335a9c99 RDX: 0000000000000006 RSI: 0000000000000000 RDI: 0000000000000004 RBP: 00007f813363b18b R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000ffff R11: 0000000000000246 R12: 0000000000000000 R13: 00007f8133836038 R14: 00007f8133835fa0 R15: 00007ffe47c43d78