====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ syz.1.358/9296 is trying to acquire lock: ffff888023c7c770 (sb_internal#4){.+.+}-{0:0}, at: btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6270 but task is already holding lock: ffff888023c7c5f8 (sb_pagefaults#6){.+.+}-{0:0}, at: do_page_mkwrite+0x150/0x310 mm/memory.c:3488 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #7 (sb_pagefaults#6){.+.+}-{0:0}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs.h:1916 [inline] sb_start_pagefault include/linux/fs.h:2081 [inline] btrfs_page_mkwrite+0x32c/0x1a80 fs/btrfs/file.c:1874 do_page_mkwrite+0x150/0x310 mm/memory.c:3488 wp_page_shared mm/memory.c:3889 [inline] do_wp_page+0x25c8/0x4930 mm/memory.c:4108 handle_pte_fault mm/memory.c:6193 [inline] __handle_mm_fault mm/memory.c:6318 [inline] handle_mm_fault+0x97c/0x3400 mm/memory.c:6487 do_user_addr_fault+0xa7c/0x1380 arch/x86/mm/fault.c:1336 handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x82/0x100 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618 -> #6 (vm_lock){++++}-{0:0}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 __vma_enter_locked+0x182/0x380 mm/mmap_lock.c:63 __vma_start_write+0x1e/0x120 mm/mmap_lock.c:87 vma_start_write include/linux/mmap_lock.h:212 [inline] mprotect_fixup+0x578/0x9c0 mm/mprotect.c:828 setup_arg_pages+0x52a/0xa90 fs/exec.c:670 load_elf_binary+0xbad/0x2750 fs/binfmt_elf.c:1028 search_binary_handler fs/exec.c:1670 [inline] exec_binprm fs/exec.c:1702 [inline] bprm_execve+0x99c/0x1450 fs/exec.c:1754 kernel_execve+0x8f0/0x9f0 fs/exec.c:1920 try_to_run_init_process+0x13/0x60 init/main.c:1411 kernel_init+0xad/0x1d0 init/main.c:1539 ret_from_fork+0x4bc/0x870 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 -> #5 (&mm->mmap_lock){++++}-{4:4}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 down_read_killable+0x9d/0x220 kernel/locking/rwsem.c:1560 mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:377 get_mmap_lock_carefully mm/mmap_lock.c:377 [inline] lock_mm_and_find_vma+0x2a8/0x300 mm/mmap_lock.c:428 do_user_addr_fault+0x331/0x1380 arch/x86/mm/fault.c:1359 handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x82/0x100 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618 filldir+0x2b6/0x6c0 fs/readdir.c:295 dir_emit include/linux/fs.h:3986 [inline] offset_dir_emit fs/libfs.c:507 [inline] offset_iterate_dir fs/libfs.c:523 [inline] offset_readdir+0x44c/0x560 fs/libfs.c:572 iterate_dir+0x3a5/0x580 fs/readdir.c:108 __do_sys_getdents fs/readdir.c:326 [inline] __se_sys_getdents+0xe4/0x250 fs/readdir.c:312 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #4 (&type->i_mutex_dir_key#5){++++}-{4:4}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 down_read+0x97/0x1f0 kernel/locking/rwsem.c:1537 inode_lock_shared include/linux/fs.h:995 [inline] lookup_slow+0x46/0x70 fs/namei.c:1832 walk_component+0x2d2/0x400 fs/namei.c:2151 lookup_last fs/namei.c:2652 [inline] path_lookupat+0x163/0x430 fs/namei.c:2676 filename_lookup+0x212/0x570 fs/namei.c:2705 kern_path+0x35/0x50 fs/namei.c:2863 is_same_device fs/btrfs/volumes.c:759 [inline] device_list_add+0xe2a/0x22a0 fs/btrfs/volumes.c:894 btrfs_scan_one_device+0x3ee/0x650 fs/btrfs/volumes.c:1493 btrfs_get_tree_super fs/btrfs/super.c:1865 [inline] btrfs_get_tree_subvol fs/btrfs/super.c:2094 [inline] btrfs_get_tree+0x4ab/0x1920 fs/btrfs/super.c:2128 vfs_get_tree+0x92/0x2b0 fs/super.c:1751 fc_mount fs/namespace.c:1208 [inline] do_new_mount_fc fs/namespace.c:3651 [inline] do_new_mount+0x302/0xa10 fs/namespace.c:3727 do_mount fs/namespace.c:4050 [inline] __do_sys_mount fs/namespace.c:4238 [inline] __se_sys_mount+0x313/0x410 fs/namespace.c:4215 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #3 (&fs_devs->device_list_mutex){+.+.}-{4:4}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 __mutex_lock_common kernel/locking/rtmutex_api.c:535 [inline] mutex_lock_nested+0x5a/0x1d0 kernel/locking/rtmutex_api.c:547 insert_dev_extents fs/btrfs/block-group.c:2754 [inline] btrfs_create_pending_block_groups+0x5f8/0x1780 fs/btrfs/block-group.c:2805 __btrfs_end_transaction+0x140/0x640 fs/btrfs/transaction.c:1071 btrfs_inc_block_group_ro+0x641/0x6f0 fs/btrfs/block-group.c:3092 btrfs_relocate_block_group+0x29d/0xba0 fs/btrfs/relocation.c:3936 btrfs_relocate_chunk+0x12f/0x5d0 fs/btrfs/volumes.c:3451 __btrfs_balance+0x186f/0x23f0 fs/btrfs/volumes.c:4227 btrfs_balance+0xac2/0x11b0 fs/btrfs/volumes.c:4604 btrfs_ioctl_balance+0x3d6/0x610 fs/btrfs/ioctl.c:3577 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl+0xff/0x170 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #2 (btrfs_trans_num_extwriters){++++}-{0:0}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 join_transaction+0x1a4/0xca0 fs/btrfs/transaction.c:321 start_transaction+0x6b6/0x1620 fs/btrfs/transaction.c:705 btrfs_link+0x335/0xaf0 fs/btrfs/inode.c:6865 vfs_link+0x4ed/0x6e0 fs/namei.c:4941 do_linkat+0x272/0x560 fs/namei.c:5011 __do_sys_link fs/namei.c:5045 [inline] __se_sys_link fs/namei.c:5043 [inline] __x64_sys_link+0x82/0x90 fs/namei.c:5043 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (btrfs_trans_num_writers){++++}-{0:0}: lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 join_transaction+0x182/0xca0 fs/btrfs/transaction.c:320 start_transaction+0x6b6/0x1620 fs/btrfs/transaction.c:705 btrfs_link+0x335/0xaf0 fs/btrfs/inode.c:6865 vfs_link+0x4ed/0x6e0 fs/namei.c:4941 do_linkat+0x272/0x560 fs/namei.c:5011 __do_sys_link fs/namei.c:5045 [inline] __se_sys_link fs/namei.c:5043 [inline] __x64_sys_link+0x82/0x90 fs/namei.c:5043 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (sb_internal#4){.+.+}-{0:0}: check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3908 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5237 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs.h:1916 [inline] sb_start_intwrite include/linux/fs.h:2099 [inline] start_transaction+0x56e/0x1620 fs/btrfs/transaction.c:699 btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6270 inode_update_time fs/inode.c:2117 [inline] __file_update_time fs/inode.c:2345 [inline] file_update_time+0x34d/0x490 fs/inode.c:2375 btrfs_page_mkwrite+0x5dd/0x1a80 fs/btrfs/file.c:1915 do_page_mkwrite+0x150/0x310 mm/memory.c:3488 wp_page_shared mm/memory.c:3889 [inline] do_wp_page+0x25c8/0x4930 mm/memory.c:4108 handle_pte_fault mm/memory.c:6193 [inline] __handle_mm_fault mm/memory.c:6318 [inline] handle_mm_fault+0x97c/0x3400 mm/memory.c:6487 do_user_addr_fault+0xa7c/0x1380 arch/x86/mm/fault.c:1336 handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x82/0x100 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618 other info that might help us debug this: Chain exists of: sb_internal#4 --> vm_lock --> sb_pagefaults#6 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(sb_pagefaults#6); lock(vm_lock); lock(sb_pagefaults#6); rlock(sb_internal#4); *** DEADLOCK *** 2 locks held by syz.1.358/9296: #0: ffff88803119ebc8 (vm_lock){++++}-{0:0}, at: lock_vma_under_rcu+0x1a3/0x450 mm/mmap_lock.c:238 #1: ffff888023c7c5f8 (sb_pagefaults#6){.+.+}-{0:0}, at: do_page_mkwrite+0x150/0x310 mm/memory.c:3488 stack backtrace: CPU: 1 UID: 0 PID: 9296 Comm: syz.1.358 Not tainted syzkaller #0 PREEMPT_{RT,(full)} Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/02/2025 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2043 check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2175 check_prev_add kernel/locking/lockdep.c:3165 [inline] check_prevs_add kernel/locking/lockdep.c:3284 [inline] validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3908 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5237 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs.h:1916 [inline] sb_start_intwrite include/linux/fs.h:2099 [inline] start_transaction+0x56e/0x1620 fs/btrfs/transaction.c:699 btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6270 inode_update_time fs/inode.c:2117 [inline] __file_update_time fs/inode.c:2345 [inline] file_update_time+0x34d/0x490 fs/inode.c:2375 btrfs_page_mkwrite+0x5dd/0x1a80 fs/btrfs/file.c:1915 do_page_mkwrite+0x150/0x310 mm/memory.c:3488 wp_page_shared mm/memory.c:3889 [inline] do_wp_page+0x25c8/0x4930 mm/memory.c:4108 handle_pte_fault mm/memory.c:6193 [inline] __handle_mm_fault mm/memory.c:6318 [inline] handle_mm_fault+0x97c/0x3400 mm/memory.c:6487 do_user_addr_fault+0xa7c/0x1380 arch/x86/mm/fault.c:1336 handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x82/0x100 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618 RIP: 0033:0x7f1f2c516c18 Code: fc 89 37 c3 c5 fa 6f 06 c5 fa 6f 4c 16 f0 c5 fa 7f 07 c5 fa 7f 4c 17 f0 c3 66 0f 1f 84 00 00 00 00 00 48 8b 4c 16 f8 48 8b 36 <48> 89 37 48 89 4c 17 f8 c3 c5 fe 6f 54 16 e0 c5 fe 6f 5c 16 c0 c5 RSP: 002b:00007ffe4e2ca538 EFLAGS: 00010246 RAX: 0000200000000300 RBX: 0000000000000004 RCX: 0031656c69662f2e RDX: 0000000000000008 RSI: 0031656c69662f2e RDI: 0000200000000300 RBP: 00007f1f2c7a7da0 R08: 0000001b32920000 R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000009 R12: 00007f1f2c7a5fac R13: 00007f1f2c7a5fa0 R14: fffffffffffffffe R15: 00007ffe4e2ca650