====================================================== WARNING: possible circular locking dependency detected 5.15.178-syzkaller #0 Not tainted ------------------------------------------------------ syz.6.1126/9192 is trying to acquire lock: ffff888078470f28 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 but task is already holding lock: ffff88805e543438 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: iterate_dir+0x10a/0x570 fs/readdir.c:55 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&type->i_mutex_dir_key#3){++++}-{3:3}: lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623 down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:799 [inline] lookup_slow+0x45/0x70 fs/namei.c:1679 walk_component+0x48c/0x610 fs/namei.c:1976 lookup_last fs/namei.c:2431 [inline] path_lookupat+0x16f/0x450 fs/namei.c:2455 filename_lookup+0x230/0x5c0 fs/namei.c:2484 kern_path+0x37/0x180 fs/namei.c:2582 lookup_bdev+0xc1/0x280 block/bdev.c:979 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x71f/0xb00 fs/btrfs/volumes.c:608 btrfs_forget_devices+0x52/0x80 fs/btrfs/volumes.c:1431 btrfs_control_ioctl+0x108/0x210 fs/btrfs/super.c:2451 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #2 (&fs_devs->device_list_mutex){+.+.}-{3:3}: lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623 __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:2395 [inline] btrfs_create_pending_block_groups+0x5c1/0x1130 fs/btrfs/block-group.c:2445 __btrfs_end_transaction+0x296/0x780 fs/btrfs/transaction.c:1014 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:2310 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457 kthread+0x3f6/0x4f0 kernel/kthread.c:334 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287 -> #1 (sb_internal#4){.+.+}-{0:0}: lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623 percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1813 [inline] sb_start_intwrite include/linux/fs.h:1930 [inline] start_transaction+0x5a8/0x11a0 fs/btrfs/transaction.c:678 btrfs_dirty_inode+0xcc/0x1c0 fs/btrfs/inode.c:6436 inode_update_time fs/inode.c:1868 [inline] touch_atime+0x34e/0x680 fs/inode.c:1941 file_accessed include/linux/fs.h:2523 [inline] btrfs_file_mmap+0xbf/0x120 fs/btrfs/file.c:2451 call_mmap include/linux/fs.h:2179 [inline] mmap_file+0x5a/0xb0 mm/util.c:1092 __mmap_region mm/mmap.c:1784 [inline] mmap_region+0x1035/0x1870 mm/mmap.c:2921 do_mmap+0x78d/0xe00 mm/mmap.c:1574 vm_mmap_pgoff+0x1ca/0x2d0 mm/util.c:551 ksys_mmap_pgoff+0x559/0x780 mm/mmap.c:1623 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0xb0 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+0x1649/0x5930 kernel/locking/lockdep.c:3788 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623 down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498 mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 do_user_addr_fault arch/x86/mm/fault.c:1308 [inline] handle_page_fault arch/x86/mm/fault.c:1445 [inline] exc_page_fault+0x596/0x700 arch/x86/mm/fault.c:1501 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:606 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:3721 [inline] dir_emit_dots include/linux/fs.h:3732 [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+0x3b/0xb0 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.6.1126/9192: #0: ffff88804f20e870 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2cb/0x380 fs/file.c:1058 #1: ffff88805e543438 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: iterate_dir+0x10a/0x570 fs/readdir.c:55 stack backtrace: CPU: 1 PID: 9192 Comm: syz.6.1126 Not tainted 5.15.178-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2d0 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+0x1649/0x5930 kernel/locking/lockdep.c:3788 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623 down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498 mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 do_user_addr_fault arch/x86/mm/fault.c:1308 [inline] handle_page_fault arch/x86/mm/fault.c:1445 [inline] exc_page_fault+0x596/0x700 arch/x86/mm/fault.c:1501 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:606 RIP: 0010:filldir64+0x32b/0x730 fs/readdir.c:335 Code: fd 0f 82 60 02 00 00 48 b8 00 f0 ff ff ff 7f 00 00 48 39 c5 0f 87 4d 02 00 00 0f 01 cb 0f ae e8 48 8b 44 24 60 48 8b 4c 24 18 <48> 89 41 08 48 8b 44 24 10 48 8b 4c 24 58 48 89 08 48 8b 4c 24 20 RSP: 0018:ffffc900034efc68 EFLAGS: 00050283 RAX: 0000000000000000 RBX: 0000400000000058 RCX: 0000400000000040 RDX: 0000000000000000 RSI: 0000400000000058 RDI: 00007ffffffff000 RBP: 0000400000000058 R08: ffffffff81db1fdf R09: 0000000000000004 R10: 0000000000000003 R11: ffff888058ca3b80 R12: ffffffff8ab72a40 R13: ffffc900034efe70 R14: 0000000000000001 R15: 0000400000000040 dir_emit_dot include/linux/fs.h:3721 [inline] dir_emit_dots include/linux/fs.h:3732 [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+0x3b/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 RIP: 0033:0x7fa8e367b169 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fa8e14e4038 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9 RAX: ffffffffffffffda RBX: 00007fa8e3893fa0 RCX: 00007fa8e367b169 RDX: 0000000000000034 RSI: 0000400000000040 RDI: 0000000000000003 RBP: 00007fa8e36fc2a0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fa8e3893fa0 R15: 00007ffc793b8328 ---------------- Code disassembly (best guess): 0: fd std 1: 0f 82 60 02 00 00 jb 0x267 7: 48 b8 00 f0 ff ff ff movabs $0x7ffffffff000,%rax e: 7f 00 00 11: 48 39 c5 cmp %rax,%rbp 14: 0f 87 4d 02 00 00 ja 0x267 1a: 0f 01 cb stac 1d: 0f ae e8 lfence 20: 48 8b 44 24 60 mov 0x60(%rsp),%rax 25: 48 8b 4c 24 18 mov 0x18(%rsp),%rcx * 2a: 48 89 41 08 mov %rax,0x8(%rcx) <-- trapping instruction 2e: 48 8b 44 24 10 mov 0x10(%rsp),%rax 33: 48 8b 4c 24 58 mov 0x58(%rsp),%rcx 38: 48 89 08 mov %rcx,(%rax) 3b: 48 8b 4c 24 20 mov 0x20(%rsp),%rcx