====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ syz.3.4805/32674 is trying to acquire lock: ffff888054c8ab28 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 but task is already holding lock: ffff888017fe0278 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: iterate_dir+0x10d/0x560 fs/readdir.c:55 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (&type->i_mutex_dir_key#3){++++}-{3:3}: down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x46/0x70 fs/namei.c:1687 walk_component+0x319/0x460 fs/namei.c:1984 lookup_last fs/namei.c:2439 [inline] path_lookupat+0x169/0x440 fs/namei.c:2463 filename_lookup+0x214/0x540 fs/namei.c:2492 kern_path+0x37/0x190 fs/namei.c:2590 lookup_bdev+0xc5/0x280 block/bdev.c:982 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x6ec/0xa90 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x52/0x80 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x10a/0x220 fs/btrfs/super.c:2450 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #3 (&fs_devs->device_list_mutex){+.+.}-{3:3}: __mutex_lock_common+0x1e3/0x2400 kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743 btrfs_run_dev_stats+0xdf/0xec0 fs/btrfs/volumes.c:7998 commit_cowonly_roots+0x185/0x9c0 fs/btrfs/transaction.c:1293 btrfs_commit_transaction+0x130d/0x3570 fs/btrfs/transaction.c:2395 close_ctree+0x3fb/0x8e0 fs/btrfs/disk-io.c:4470 generic_shutdown_super+0x130/0x300 fs/super.c:475 kill_anon_super+0x36/0x70 fs/super.c:1089 btrfs_kill_super+0x3d/0x50 fs/btrfs/super.c:2390 deactivate_locked_super+0x93/0xf0 fs/super.c:335 cleanup_mnt+0x42d/0x4e0 fs/namespace.c:1148 task_work_run+0x125/0x1a0 kernel/task_work.c:188 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop+0x10f/0x130 kernel/entry/common.c:181 exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:214 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline] syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:307 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #2 (&fs_info->tree_log_mutex){+.+.}-{3:3}: __lock_release kernel/locking/lockdep.c:5339 [inline] lock_release+0x321/0x8a0 kernel/locking/lockdep.c:5643 __mutex_unlock_slowpath+0xc8/0x6c0 kernel/locking/mutex.c:851 btrfs_commit_transaction+0x1d11/0x3570 fs/btrfs/transaction.c:2442 close_ctree+0x3fb/0x8e0 fs/btrfs/disk-io.c:4470 generic_shutdown_super+0x130/0x300 fs/super.c:475 kill_anon_super+0x36/0x70 fs/super.c:1089 btrfs_kill_super+0x3d/0x50 fs/btrfs/super.c:2390 deactivate_locked_super+0x93/0xf0 fs/super.c:335 cleanup_mnt+0x42d/0x4e0 fs/namespace.c:1148 task_work_run+0x125/0x1a0 kernel/task_work.c:188 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop+0x10f/0x130 kernel/entry/common.c:181 exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:214 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline] syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:307 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #1 (sb_internal#5){.+.+}-{0:0}: percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1811 [inline] sb_start_intwrite include/linux/fs.h:1928 [inline] start_transaction+0x5bc/0x1130 fs/btrfs/transaction.c:681 btrfs_dirty_inode+0xc5/0x1c0 fs/btrfs/inode.c:6451 inode_update_time fs/inode.c:1893 [inline] touch_atime+0x2f8/0x640 fs/inode.c:1966 file_accessed include/linux/fs.h:2522 [inline] btrfs_file_mmap+0xc1/0x120 fs/btrfs/file.c:2449 call_mmap include/linux/fs.h:2178 [inline] mmap_file+0x5d/0xb0 mm/util.c:1092 __mmap_region mm/mmap.c:1796 [inline] mmap_region+0xf88/0x1650 mm/mmap.c:2933 do_mmap+0x819/0xe90 mm/mmap.c:1586 vm_mmap_pgoff+0x1c1/0x2d0 mm/util.c:551 ksys_mmap_pgoff+0x54b/0x790 mm/mmap.c:1635 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #0 (&mm->mmap_lock){++++}-{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:3788 [inline] __lock_acquire+0x2c42/0x7d10 kernel/locking/lockdep.c:5012 lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623 down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498 mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 do_user_addr_fault+0xc35/0xc80 arch/x86/mm/fault.c:1306 handle_page_fault arch/x86/mm/fault.c:1443 [inline] exc_page_fault+0x60/0x100 arch/x86/mm/fault.c:1496 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:606 user_access_begin arch/x86/include/asm/uaccess.h:576 [inline] filldir+0x300/0x720 fs/readdir.c:249 dir_emit_dot include/linux/fs.h:3718 [inline] dir_emit_dots include/linux/fs.h:3729 [inline] dcache_readdir+0x173/0x7c0 fs/libfs.c:196 iterate_dir+0x218/0x560 fs/readdir.c:-1 __do_sys_getdents fs/readdir.c:286 [inline] __se_sys_getdents+0xf2/0x260 fs/readdir.c:271 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 other info that might help us debug this: Chain exists of: &mm->mmap_lock --> &fs_devs->device_list_mutex --> &type->i_mutex_dir_key#3 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&type->i_mutex_dir_key#3); lock(&fs_devs->device_list_mutex); lock(&type->i_mutex_dir_key#3); lock(&mm->mmap_lock); *** DEADLOCK *** 2 locks held by syz.3.4805/32674: #0: ffff88807ed43c70 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2bf/0x370 fs/file.c:1056 #1: ffff888017fe0278 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: iterate_dir+0x10d/0x560 fs/readdir.c:55 stack backtrace: CPU: 1 PID: 32674 Comm: syz.3.4805 Not tainted syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026 Call Trace: dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106 check_noncircular+0x296/0x330 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:3788 [inline] __lock_acquire+0x2c42/0x7d10 kernel/locking/lockdep.c:5012 lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623 down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498 mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 do_user_addr_fault+0xc35/0xc80 arch/x86/mm/fault.c:1306 handle_page_fault arch/x86/mm/fault.c:1443 [inline] exc_page_fault+0x60/0x100 arch/x86/mm/fault.c:1496 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:606 RIP: 0010:filldir+0x300/0x720 fs/readdir.c:253 Code: 60 ab ff 4c 01 fd 0f 82 66 02 00 00 48 b8 00 f0 ff ff ff 7f 00 00 48 39 c5 0f 87 53 02 00 00 0f 01 cb 0f ae e8 48 8b 44 24 50 <49> 89 47 08 48 8b 04 24 48 8b 4c 24 10 48 8b 54 24 58 48 89 11 66 RSP: 0018:ffffc9000419fcb8 EFLAGS: 00050287 RAX: 0000000000000000 RBX: ffffc9000419fe70 RCX: ffff888048a35940 RDX: 0000000000000002 RSI: 0000200000001fd8 RDI: 00007ffffffff000 RBP: 0000200000001fd8 R08: 000000000000078a R09: 0000000000000004 R10: 0000000000000002 R11: 0000000000000002 R12: 0000200000001fd8 R13: ffffffff8a371f80 R14: 0000000000000001 R15: 0000200000001fc0 dir_emit_dot include/linux/fs.h:3718 [inline] dir_emit_dots include/linux/fs.h:3729 [inline] dcache_readdir+0x173/0x7c0 fs/libfs.c:196 iterate_dir+0x218/0x560 fs/readdir.c:-1 __do_sys_getdents fs/readdir.c:286 [inline] __se_sys_getdents+0xf2/0x260 fs/readdir.c:271 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 RIP: 0033:0x7f18d6792e59 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:00007f18d49ec028 EFLAGS: 00000246 ORIG_RAX: 000000000000004e RAX: ffffffffffffffda RBX: 00007f18d6a0bfa0 RCX: 00007f18d6792e59 RDX: 00000000000000b8 RSI: 0000200000001fc0 RDI: 0000000000000004 RBP: 00007f18d6828d6f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f18d6a0c038 R14: 00007f18d6a0bfa0 R15: 00007fffa3019cc8 ---------------- Code disassembly (best guess), 1 bytes skipped: 0: ab stos %eax,%es:(%rdi) 1: ff 4c 01 fd decl -0x3(%rcx,%rax,1) 5: 0f 82 66 02 00 00 jb 0x271 b: 48 b8 00 f0 ff ff ff movabs $0x7ffffffff000,%rax 12: 7f 00 00 15: 48 39 c5 cmp %rax,%rbp 18: 0f 87 53 02 00 00 ja 0x271 1e: 0f 01 cb stac 21: 0f ae e8 lfence 24: 48 8b 44 24 50 mov 0x50(%rsp),%rax * 29: 49 89 47 08 mov %rax,0x8(%r15) <-- trapping instruction 2d: 48 8b 04 24 mov (%rsp),%rax 31: 48 8b 4c 24 10 mov 0x10(%rsp),%rcx 36: 48 8b 54 24 58 mov 0x58(%rsp),%rdx 3b: 48 89 11 mov %rdx,(%rcx) 3e: 66 data16