====================================================== WARNING: possible circular locking dependency detected 5.15.189-syzkaller #0 Not tainted ------------------------------------------------------ syz.7.567/6934 is trying to acquire lock: ffff0000c862e2d8 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0xa0/0x128 mm/memory.c:5356 but task is already holding lock: ffff0000f8bf00b0 (&tree->tree_lock#2){+.+.}-{3:3}, at: hfs_find_init+0x148/0x1c8 fs/hfs/bfind.c:-1 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #5 (&tree->tree_lock#2){+.+.}-{3:3}: __mutex_lock_common+0x194/0x1edc kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0xac/0x11c kernel/locking/mutex.c:743 hfs_find_init+0x148/0x1c8 fs/hfs/bfind.c:-1 hfs_lookup+0x11c/0x268 fs/hfs/dir.c:28 lookup_open fs/namei.c:3440 [inline] open_last_lookups fs/namei.c:3532 [inline] path_openat+0xfbc/0x26e4 fs/namei.c:3739 do_filp_open+0x164/0x330 fs/namei.c:3769 do_sys_openat2+0x128/0x3d8 fs/open.c:1253 do_sys_open fs/open.c:1269 [inline] __do_sys_openat fs/open.c:1285 [inline] __se_sys_openat fs/open.c:1280 [inline] __arm64_sys_openat+0x120/0x154 fs/open.c:1280 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #4 (&type->i_mutex_dir_key#16){++++}-{3:3}: down_read+0xc0/0x390 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:797 [inline] lookup_slow+0x4c/0x80 fs/namei.c:1679 walk_component+0x2b0/0x3a8 fs/namei.c:1976 lookup_last fs/namei.c:2431 [inline] path_lookupat+0x13c/0x3d0 fs/namei.c:2455 filename_lookup+0x180/0x414 fs/namei.c:2484 kern_path+0x4c/0x190 fs/namei.c:2582 lookup_bdev+0xbc/0x244 block/bdev.c:982 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x614/0x908 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x5c/0x98 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x130/0x248 fs/btrfs/super.c:2450 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:860 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #3 (&fs_devs->device_list_mutex){+.+.}-{3:3}: __mutex_lock_common+0x194/0x1edc kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0xac/0x11c kernel/locking/mutex.c:743 write_all_supers+0x1080/0x35a8 fs/btrfs/disk-io.c:4159 btrfs_sync_log+0x17c8/0x1f48 fs/btrfs/tree-log.c:3329 btrfs_sync_file+0x990/0xe7c fs/btrfs/file.c:2371 vfs_fsync_range+0x168/0x188 fs/sync.c:188 generic_write_sync include/linux/fs.h:2989 [inline] btrfs_file_write_iter+0x99c/0xbe8 fs/btrfs/file.c:2099 call_write_iter include/linux/fs.h:2172 [inline] new_sync_write fs/read_write.c:507 [inline] vfs_write+0x7c8/0xa2c fs/read_write.c:594 ksys_write+0x120/0x210 fs/read_write.c:647 __do_sys_write fs/read_write.c:659 [inline] __se_sys_write fs/read_write.c:656 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:656 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #2 (&fs_info->tree_log_mutex){+.+.}-{3:3}: __mutex_lock_common+0x194/0x1edc kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0xac/0x11c kernel/locking/mutex.c:743 btrfs_sync_log+0x1714/0x1f48 fs/btrfs/tree-log.c:3310 btrfs_sync_file+0x990/0xe7c fs/btrfs/file.c:2371 vfs_fsync_range+0x168/0x188 fs/sync.c:188 generic_write_sync include/linux/fs.h:2989 [inline] btrfs_file_write_iter+0x99c/0xbe8 fs/btrfs/file.c:2099 call_write_iter include/linux/fs.h:2172 [inline] new_sync_write fs/read_write.c:507 [inline] vfs_write+0x7c8/0xa2c fs/read_write.c:594 ksys_write+0x120/0x210 fs/read_write.c:647 __do_sys_write fs/read_write.c:659 [inline] __se_sys_write fs/read_write.c:656 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:656 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #1 (sb_internal#2){.+.+}-{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+0x624/0x13f0 fs/btrfs/transaction.c:680 btrfs_join_transaction+0x30/0x40 fs/btrfs/transaction.c:793 btrfs_dirty_inode+0xb4/0x1c0 fs/btrfs/inode.c:6451 btrfs_update_time+0x224/0x248 fs/btrfs/inode.c:6493 inode_update_time fs/inode.c:1893 [inline] touch_atime+0x3d0/0x914 fs/inode.c:1966 file_accessed include/linux/fs.h:2521 [inline] btrfs_file_mmap+0xb0/0x11c fs/btrfs/file.c:2449 call_mmap include/linux/fs.h:2177 [inline] mmap_file+0x6c/0xc8 mm/util.c:1092 __mmap_region mm/mmap.c:1792 [inline] mmap_region+0xadc/0x1390 mm/mmap.c:2929 do_mmap+0x67c/0xdb4 mm/mmap.c:1582 vm_mmap_pgoff+0x184/0x284 mm/util.c:551 ksys_mmap_pgoff+0x410/0x620 mm/mmap.c:1631 __do_sys_mmap arch/arm64/kernel/sys.c:28 [inline] __se_sys_mmap arch/arm64/kernel/sys.c:21 [inline] __arm64_sys_mmap+0xf8/0x110 arch/arm64/kernel/sys.c:21 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #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+0x2928/0x651c kernel/locking/lockdep.c:5012 lock_acquire+0x1f4/0x620 kernel/locking/lockdep.c:5623 __might_fault+0xc8/0x128 mm/memory.c:5357 filldir64+0x2bc/0x9e4 fs/readdir.c:335 dir_emit_dot include/linux/fs.h:3717 [inline] hfs_readdir+0x2fc/0x980 fs/hfs/dir.c:72 iterate_dir+0x1f0/0x4cc fs/readdir.c:-1 __do_sys_getdents64 fs/readdir.c:369 [inline] __se_sys_getdents64 fs/readdir.c:354 [inline] __arm64_sys_getdents64+0x11c/0x340 fs/readdir.c:354 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 other info that might help us debug this: Chain exists of: &mm->mmap_lock --> &type->i_mutex_dir_key#16 --> &tree->tree_lock#2 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&tree->tree_lock#2); lock(&type->i_mutex_dir_key#16); lock(&tree->tree_lock#2); lock(&mm->mmap_lock); *** DEADLOCK *** 3 locks held by syz.7.567/6934: #0: ffff0000e836bc70 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x118/0x170 fs/file.c:1058 #1: ffff0000da231628 (&type->i_mutex_dir_key#16){++++}-{3:3}, at: iterate_dir+0x108/0x4cc fs/readdir.c:55 #2: ffff0000f8bf00b0 (&tree->tree_lock#2){+.+.}-{3:3}, at: hfs_find_init+0x148/0x1c8 fs/hfs/bfind.c:-1 stack backtrace: CPU: 0 PID: 6934 Comm: syz.7.567 Not tainted 5.15.189-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 Call trace: dump_backtrace+0x0/0x43c arch/arm64/kernel/stacktrace.c:152 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216 __dump_stack+0x30/0x40 lib/dump_stack.c:88 dump_stack_lvl+0xf8/0x160 lib/dump_stack.c:106 dump_stack+0x1c/0x5c lib/dump_stack.c:113 print_circular_bug+0x148/0x1b0 kernel/locking/lockdep.c:2011 check_noncircular+0x240/0x2d4 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+0x2928/0x651c kernel/locking/lockdep.c:5012 lock_acquire+0x1f4/0x620 kernel/locking/lockdep.c:5623 __might_fault+0xc8/0x128 mm/memory.c:5357 filldir64+0x2bc/0x9e4 fs/readdir.c:335 dir_emit_dot include/linux/fs.h:3717 [inline] hfs_readdir+0x2fc/0x980 fs/hfs/dir.c:72 iterate_dir+0x1f0/0x4cc fs/readdir.c:-1 __do_sys_getdents64 fs/readdir.c:369 [inline] __se_sys_getdents64 fs/readdir.c:354 [inline] __arm64_sys_getdents64+0x11c/0x340 fs/readdir.c:354 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584