loop2: detected capacity change from 0 to 32768 BTRFS: device fsid 4c645aab-a6bb-4c7f-acba-f49e7dbd8268 devid 1 transid 8 /dev/loop2 scanned by syz-executor.2 (32737) ====================================================== WARNING: possible circular locking dependency detected 5.15.120-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.2/32737 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: ffff8880778c88e0 (&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_metadata_space+0x29b/0x340 fs/btrfs/space-info.c:953 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2307 worker_thread+0xaca/0x1280 kernel/workqueue.c:2454 kthread+0x3f6/0x4f0 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 -> #2 (sb_internal#2){.+.+}-{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+0x45/0x2e0 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 user_access_begin arch/x86/include/asm/uaccess.h:574 [inline] filldir64+0x32b/0x730 fs/readdir.c:331 dir_emit_dot include/linux/fs.h:3605 [inline] dir_emit_dots include/linux/fs.h:3616 [inline] dcache_readdir+0x181/0x800 fs/libfs.c:196 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+0x45/0x2e0 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+0x4b4/0x930 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/0xae0 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#2 --> &fs_devs->device_list_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&fs_devs->device_list_mutex); lock(sb_internal#2); lock(&fs_devs->device_list_mutex); lock(&type->i_mutex_dir_key#2); *** DEADLOCK *** 2 locks held by syz-executor.2/32737: #0: ffffffff8cdf48c8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_mount_root+0x27b/0x930 fs/btrfs/super.c:1709 #1: ffff8880778c88e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_free_stale_devices+0x14b/0xb00 fs/btrfs/volumes.c:603 stack backtrace: CPU: 1 PID: 32737 Comm: syz-executor.2 Not tainted 5.15.120-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/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+0x45/0x2e0 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+0x4b4/0x930 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/0xae0 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:0x7f19b939922a Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f19b7918ee8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f19b7918f80 RCX: 00007f19b939922a RDX: 00000000200055c0 RSI: 0000000020005600 RDI: 00007f19b7918f40 RBP: 00000000200055c0 R08: 00007f19b7918f80 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000020005600 R13: 00007f19b7918f40 R14: 000000000000559c R15: 0000000020005640 BTRFS info (device loop2): using blake2b (blake2b-256-generic) checksum algorithm BTRFS info (device loop2): using free space tree BTRFS info (device loop2): has skinny extents BTRFS info (device loop2): enabling ssd optimizations