====================================================== WARNING: possible circular locking dependency detected 5.15.156-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.3/8427 is trying to acquire lock: ffff0000e9365ce8 (&ei->i_mmap_lock){++++}-{3:3}, at: btrfs_page_mkwrite+0x530/0xde8 fs/btrfs/inode.c:8942 but task is already holding lock: ffff0000e6290558 (sb_pagefaults#3){.+.+}-{0:0}, at: do_page_mkwrite+0x144/0x37c mm/memory.c:2892 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #6 (sb_pagefaults#3){.+.+}-{0:0}: percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write include/linux/fs.h:1811 [inline] sb_start_pagefault include/linux/fs.h:1910 [inline] btrfs_page_mkwrite+0x254/0xde8 fs/btrfs/inode.c:8914 do_page_mkwrite+0x144/0x37c mm/memory.c:2892 do_shared_fault mm/memory.c:4298 [inline] do_fault mm/memory.c:4366 [inline] handle_pte_fault mm/memory.c:4621 [inline] __handle_mm_fault mm/memory.c:4756 [inline] handle_mm_fault+0x1a20/0x3424 mm/memory.c:4854 __do_page_fault arch/arm64/mm/fault.c:505 [inline] do_page_fault+0x700/0xb60 arch/arm64/mm/fault.c:605 do_translation_fault+0xe8/0x138 arch/arm64/mm/fault.c:686 do_mem_abort+0x70/0x1d8 arch/arm64/mm/fault.c:819 el0_da+0x94/0x20c arch/arm64/kernel/entry-common.c:494 el0t_64_sync_handler+0xc0/0xe4 arch/arm64/kernel/entry-common.c:629 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #5 (&mm->mmap_lock){++++}-{3:3}: __might_fault+0xc8/0x128 mm/memory.c:5328 filldir64+0x2bc/0x9e4 fs/readdir.c:335 dir_emit_dot include/linux/fs.h:3678 [inline] hfsplus_readdir+0x398/0xf68 fs/hfsplus/dir.c:159 iterate_dir+0x1f4/0x4e4 __do_sys_getdents64 fs/readdir.c:369 [inline] __se_sys_getdents64 fs/readdir.c:354 [inline] __arm64_sys_getdents64+0x1c4/0x4c4 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+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #4 (&tree->tree_lock){+.+.}-{3:3}: __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743 hfsplus_find_init+0x144/0x1bc hfsplus_lookup+0x17c/0x98c fs/hfsplus/dir.c:44 __lookup_slow+0x250/0x388 fs/namei.c:1663 lookup_slow+0x60/0x84 fs/namei.c:1680 walk_component+0x394/0x4cc fs/namei.c:1976 lookup_last fs/namei.c:2431 [inline] path_lookupat+0x13c/0x3d0 fs/namei.c:2455 filename_lookup+0x1c4/0x4c8 fs/namei.c:2484 user_path_at_empty+0x5c/0x1a4 fs/namei.c:2883 user_path_at include/linux/namei.h:57 [inline] do_sys_truncate+0xb4/0x1b4 fs/open.c:132 __do_sys_truncate fs/open.c:146 [inline] __se_sys_truncate fs/open.c:144 [inline] __arm64_sys_truncate+0x5c/0x70 fs/open.c:144 __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+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #3 (&type->i_mutex_dir_key#15){++++}-{3:3}: down_read+0xc0/0x398 kernel/locking/rwsem.c:1498 inode_lock_shared include/linux/fs.h:799 [inline] lookup_slow+0x50/0x84 fs/namei.c:1679 walk_component+0x394/0x4cc fs/namei.c:1976 link_path_walk+0x5a0/0xc38 path_lookupat+0x90/0x3d0 fs/namei.c:2454 filename_lookup+0x1c4/0x4c8 fs/namei.c:2484 kern_path+0x4c/0x194 fs/namei.c:2582 lookup_bdev+0xc0/0x25c block/bdev.c:979 device_matched fs/btrfs/volumes.c:568 [inline] btrfs_free_stale_devices+0x658/0x9ec fs/btrfs/volumes.c:608 btrfs_forget_devices+0x5c/0x98 fs/btrfs/volumes.c:1388 btrfs_control_ioctl+0x12c/0x248 fs/btrfs/super.c:2451 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+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #2 (&fs_devs->device_list_mutex){+.+.}-{3:3}: __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596 __mutex_lock kernel/locking/mutex.c:729 [inline] mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743 insert_dev_extents fs/btrfs/block-group.c:2379 [inline] btrfs_create_pending_block_groups+0x490/0xebc fs/btrfs/block-group.c:2429 __btrfs_end_transaction+0x13c/0x610 fs/btrfs/transaction.c:1014 btrfs_end_transaction+0x24/0x34 fs/btrfs/transaction.c:1050 btrfs_inc_block_group_ro+0x4dc/0x54c fs/btrfs/block-group.c:2644 btrfs_relocate_block_group+0x2c0/0x8bc fs/btrfs/relocation.c:4041 btrfs_relocate_chunk+0xb8/0x280 fs/btrfs/volumes.c:3289 __btrfs_balance+0x1214/0x1e20 fs/btrfs/volumes.c:4029 btrfs_balance+0xaa8/0x111c fs/btrfs/volumes.c:4419 btrfs_ioctl_balance+0x50c/0x7b4 fs/btrfs/ioctl.c:4152 btrfs_ioctl+0x8d4/0xa5c fs/btrfs/ioctl.c:5012 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+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0x84/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+0x644/0x1480 fs/btrfs/transaction.c:678 btrfs_start_transaction+0x34/0x44 fs/btrfs/transaction.c:777 btrfs_sync_file+0x808/0xe60 fs/btrfs/file.c:2316 vfs_fsync_range+0x168/0x188 fs/sync.c:188 generic_write_sync include/linux/fs.h:2984 [inline] btrfs_file_write_iter+0x758/0xad8 fs/btrfs/file.c:2093 call_write_iter include/linux/fs.h:2172 [inline] new_sync_write fs/read_write.c:507 [inline] vfs_write+0x87c/0xb3c fs/read_write.c:594 ksys_pwrite64 fs/read_write.c:701 [inline] __do_sys_pwrite64 fs/read_write.c:711 [inline] __se_sys_pwrite64 fs/read_write.c:708 [inline] __arm64_sys_pwrite64+0x188/0x220 fs/read_write.c:708 __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+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 -> #0 (&ei->i_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+0x32d4/0x7638 kernel/locking/lockdep.c:5012 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623 down_read+0xc0/0x398 kernel/locking/rwsem.c:1498 btrfs_page_mkwrite+0x530/0xde8 fs/btrfs/inode.c:8942 do_page_mkwrite+0x144/0x37c mm/memory.c:2892 do_shared_fault mm/memory.c:4298 [inline] do_fault mm/memory.c:4366 [inline] handle_pte_fault mm/memory.c:4621 [inline] __handle_mm_fault mm/memory.c:4756 [inline] handle_mm_fault+0x1a20/0x3424 mm/memory.c:4854 __do_page_fault arch/arm64/mm/fault.c:505 [inline] do_page_fault+0x700/0xb60 arch/arm64/mm/fault.c:605 do_translation_fault+0xe8/0x138 arch/arm64/mm/fault.c:686 do_mem_abort+0x70/0x1d8 arch/arm64/mm/fault.c:819 el0_da+0x94/0x20c arch/arm64/kernel/entry-common.c:494 el0t_64_sync_handler+0xc0/0xe4 arch/arm64/kernel/entry-common.c:629 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584 other info that might help us debug this: Chain exists of: &ei->i_mmap_lock --> &mm->mmap_lock --> sb_pagefaults#3 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(sb_pagefaults#3); lock(&mm->mmap_lock); lock(sb_pagefaults#3); lock(&ei->i_mmap_lock); *** DEADLOCK *** 2 locks held by syz-executor.3/8427: #0: ffff0000d9249258 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:117 [inline] #0: ffff0000d9249258 (&mm->mmap_lock){++++}-{3:3}, at: do_page_fault+0x66c/0xb60 arch/arm64/mm/fault.c:590 #1: ffff0000e6290558 (sb_pagefaults#3){.+.+}-{0:0}, at: do_page_mkwrite+0x144/0x37c mm/memory.c:2892 stack backtrace: CPU: 0 PID: 8427 Comm: syz-executor.3 Not tainted 5.15.156-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024 Call trace: dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106 dump_stack+0x1c/0x58 lib/dump_stack.c:113 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011 check_noncircular+0x2cc/0x378 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+0x32d4/0x7638 kernel/locking/lockdep.c:5012 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623 down_read+0xc0/0x398 kernel/locking/rwsem.c:1498 btrfs_page_mkwrite+0x530/0xde8 fs/btrfs/inode.c:8942 do_page_mkwrite+0x144/0x37c mm/memory.c:2892 do_shared_fault mm/memory.c:4298 [inline] do_fault mm/memory.c:4366 [inline] handle_pte_fault mm/memory.c:4621 [inline] __handle_mm_fault mm/memory.c:4756 [inline] handle_mm_fault+0x1a20/0x3424 mm/memory.c:4854 __do_page_fault arch/arm64/mm/fault.c:505 [inline] do_page_fault+0x700/0xb60 arch/arm64/mm/fault.c:605 do_translation_fault+0xe8/0x138 arch/arm64/mm/fault.c:686 do_mem_abort+0x70/0x1d8 arch/arm64/mm/fault.c:819 el0_da+0x94/0x20c arch/arm64/kernel/entry-common.c:494 el0t_64_sync_handler+0xc0/0xe4 arch/arm64/kernel/entry-common.c:629 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584