BTRFS: device fsid 24c7a497-3402-47dd-bef8-82358f5f30e0 devid 1 transid 8 /dev/loop3 scanned by syz-executor.3 (28675) ====================================================== WARNING: possible circular locking dependency detected 5.15.110-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.3/28675 is trying to acquire lock: ffff888011e588b0 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: inode_lock_shared include/linux/fs.h:797 [inline] ffff888011e588b0 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: lookup_slow+0x45/0x70 fs/namei.c:1675 but task is already holding lock: ffff88806c9d80e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_free_stale_devices+0x14b/0xb00 fs/btrfs/volumes.c:603 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&fs_devs->device_list_mutex){+.+.}-{3:3}: lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622 __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743 insert_dev_extents fs/btrfs/block-group.c:2345 [inline] btrfs_create_pending_block_groups+0x5c1/0x1130 fs/btrfs/block-group.c:2395 __btrfs_end_transaction+0x296/0x780 fs/btrfs/transaction.c:1007 flush_space+0x4cf/0xd50 fs/btrfs/space-info.c:674 btrfs_async_reclaim_data_space+0x118/0x3e0 fs/btrfs/space-info.c:1169 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2306 worker_thread+0xaca/0x1280 kernel/workqueue.c:2453 kthread+0x3f6/0x4f0 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 -> #2 (sb_internal#3){.+.+}-{0:0}: lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622 percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1742 [inline] sb_start_intwrite include/linux/fs.h:1859 [inline] start_transaction+0x5a8/0x11a0 fs/btrfs/transaction.c:677 btrfs_dirty_inode+0xcc/0x1c0 fs/btrfs/inode.c:6322 inode_update_time fs/inode.c:1787 [inline] touch_atime+0x34e/0x680 fs/inode.c:1860 file_accessed include/linux/fs.h:2447 [inline] btrfs_file_mmap+0xbf/0x120 fs/btrfs/file.c:2424 call_mmap include/linux/fs.h:2108 [inline] mmap_region+0x10e7/0x1670 mm/mmap.c:1791 do_mmap+0x78d/0xe00 mm/mmap.c:1575 vm_mmap_pgoff+0x1ca/0x2d0 mm/util.c:551 ksys_mmap_pgoff+0x559/0x780 mm/mmap.c:1624 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+0x61/0xcb -> #1 (&mm->mmap_lock#2){++++}-{3:3}: lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622 down_read+0x3b/0x50 kernel/locking/rwsem.c:1488 mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 do_user_addr_fault arch/x86/mm/fault.c:1348 [inline] handle_page_fault arch/x86/mm/fault.c:1485 [inline] exc_page_fault+0x5ce/0x740 arch/x86/mm/fault.c:1541 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568 filldir64+0x34f/0x730 dir_emit include/linux/fs.h:3601 [inline] dcache_readdir+0x45f/0x800 fs/libfs.c:207 iterate_dir+0x224/0x570 __do_sys_getdents64 fs/readdir.c:369 [inline] __se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354 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+0x61/0xcb -> #0 (&type->i_mutex_dir_key#2){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3053 [inline] check_prevs_add kernel/locking/lockdep.c:3172 [inline] validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622 down_read+0x3b/0x50 kernel/locking/rwsem.c:1488 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x45/0x70 fs/namei.c:1675 walk_component+0x48c/0x610 fs/namei.c:1972 lookup_last fs/namei.c:2427 [inline] path_lookupat+0x16f/0x450 fs/namei.c:2451 filename_lookup+0x230/0x5c0 fs/namei.c:2480 kern_path+0x37/0x180 fs/namei.c:2570 lookup_bdev+0xc1/0x280 block/bdev.c:979 device_matched fs/btrfs/volumes.c:563 [inline] btrfs_free_stale_devices+0x6cc/0xb00 fs/btrfs/volumes.c:608 btrfs_scan_one_device+0x494/0x690 fs/btrfs/volumes.c:1440 btrfs_mount_root+0x4bd/0x940 fs/btrfs/super.c:1716 legacy_get_tree+0xeb/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1508 fc_mount fs/namespace.c:1000 [inline] vfs_kern_mount+0xb8/0x150 fs/namespace.c:1030 btrfs_mount+0x395/0xb40 fs/btrfs/super.c:1812 legacy_get_tree+0xeb/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1508 do_new_mount+0x28b/0xad0 fs/namespace.c:2994 do_mount fs/namespace.c:3337 [inline] __do_sys_mount fs/namespace.c:3545 [inline] __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3522 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+0x61/0xcb other info that might help us debug this: Chain exists of: &type->i_mutex_dir_key#2 --> sb_internal#3 --> &fs_devs->device_list_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&fs_devs->device_list_mutex); lock(sb_internal#3); lock(&fs_devs->device_list_mutex); lock(&type->i_mutex_dir_key#2); *** DEADLOCK *** 2 locks held by syz-executor.3/28675: #0: ffffffff8cdf1e08 ( uuid_mutex){+.+.}-{3:3}, at: btrfs_mount_root+0x281/0x940 fs/btrfs/super.c:1709 #1: ffff88806c9d80e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_free_stale_devices+0x14b/0xb00 fs/btrfs/volumes.c:603 stack backtrace: CPU: 1 PID: 28675 Comm: syz-executor.3 Not tainted 5.15.110-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 check_noncircular+0x2f8/0x3b0 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+0x1646/0x58b0 kernel/locking/lockdep.c:3787 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622 down_read+0x3b/0x50 kernel/locking/rwsem.c:1488 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x45/0x70 fs/namei.c:1675 walk_component+0x48c/0x610 fs/namei.c:1972 lookup_last fs/namei.c:2427 [inline] path_lookupat+0x16f/0x450 fs/namei.c:2451 filename_lookup+0x230/0x5c0 fs/namei.c:2480 kern_path+0x37/0x180 fs/namei.c:2570 lookup_bdev+0xc1/0x280 block/bdev.c:979 device_matched fs/btrfs/volumes.c:563 [inline] btrfs_free_stale_devices+0x6cc/0xb00 fs/btrfs/volumes.c:608 btrfs_scan_one_device+0x494/0x690 fs/btrfs/volumes.c:1440 btrfs_mount_root+0x4bd/0x940 fs/btrfs/super.c:1716 legacy_get_tree+0xeb/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1508 fc_mount fs/namespace.c:1000 [inline] vfs_kern_mount+0xb8/0x150 fs/namespace.c:1030 btrfs_mount+0x395/0xb40 fs/btrfs/super.c:1812 legacy_get_tree+0xeb/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1508 do_new_mount+0x28b/0xad0 fs/namespace.c:2994 do_mount fs/namespace.c:3337 [inline] __do_sys_mount fs/namespace.c:3545 [inline] __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3522 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+0x61/0xcb RIP: 0033:0x7f900c4b869a Code: 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 b8 04 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 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:00007f900aa28f88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00000000000050ef RCX: 00007f900c4b869a RDX: 0000000020005100 RSI: 0000000020000000 RDI: 00007f900aa28fe0 RBP: 00007f900aa29020 R08: 00007f900aa29020 R09: 0000000000000080 R10: 0000000000000080 R11: 0000000000000202 R12: 0000000020005100 R13: 0000000020000000 R14: 00007f900aa28fe0 R15: 0000000020000040 BTRFS info (device loop3): using crc32c (crc32c-intel) checksum algorithm BTRFS info (device loop3): doing ref verification BTRFS warning (device loop3): the 'inode_cache' option is deprecated and has no effect since 5.11 BTRFS info (device loop3): force zlib compression, level 3 BTRFS info (device loop3): allowing degraded mounts BTRFS info (device loop3): using free space tree BTRFS info (device loop3): has skinny extents BTRFS error (device loop3): open_ctree failed