====================================================== WARNING: possible circular locking dependency detected 6.1.25-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.3/8280 is trying to acquire lock: ffff0000cb55a0f8 (&sbi->alloc_mutex){+.+.}-{3:3}, at: hfsplus_block_free+0xcc/0x4b0 fs/hfsplus/bitmap.c:182 but task is already holding lock: ffff000123e41548 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x250/0x9b8 fs/hfsplus/extents.c:576 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}: __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799 hfsplus_get_block+0x2c4/0x1168 fs/hfsplus/extents.c:260 block_read_full_folio+0x2f4/0x98c fs/buffer.c:2271 hfsplus_read_folio+0x28/0x38 fs/hfsplus/inode.c:28 filemap_read_folio+0x14c/0x39c mm/filemap.c:2407 do_read_cache_folio+0x24c/0x544 mm/filemap.c:3535 do_read_cache_page mm/filemap.c:3577 [inline] read_cache_page+0x6c/0x180 mm/filemap.c:3586 read_mapping_page include/linux/pagemap.h:756 [inline] hfsplus_block_allocate+0xe0/0x818 fs/hfsplus/bitmap.c:37 hfsplus_file_extend+0x770/0x14cc fs/hfsplus/extents.c:468 hfsplus_get_block+0x398/0x1168 fs/hfsplus/extents.c:245 __block_write_begin_int+0x340/0x13b4 fs/buffer.c:1991 __block_write_begin fs/buffer.c:2041 [inline] block_write_begin fs/buffer.c:2102 [inline] cont_write_begin+0x5c0/0x7d8 fs/buffer.c:2456 hfsplus_write_begin+0x98/0xe4 fs/hfsplus/inode.c:52 page_symlink+0x278/0x4a4 fs/namei.c:5121 hfsplus_symlink+0xc0/0x224 fs/hfsplus/dir.c:449 vfs_symlink+0x244/0x3a8 fs/namei.c:4401 do_symlinkat+0x364/0x6b0 fs/namei.c:4430 __do_sys_symlinkat fs/namei.c:4447 [inline] __se_sys_symlinkat fs/namei.c:4444 [inline] __arm64_sys_symlinkat+0xa4/0xbc fs/namei.c:4444 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581 -> #0 (&sbi->alloc_mutex){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:3098 [inline] check_prevs_add kernel/locking/lockdep.c:3217 [inline] validate_chain kernel/locking/lockdep.c:3832 [inline] __lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799 hfsplus_block_free+0xcc/0x4b0 fs/hfsplus/bitmap.c:182 hfsplus_free_extents+0x148/0x8d4 fs/hfsplus/extents.c:363 hfsplus_file_truncate+0x698/0x9b8 fs/hfsplus/extents.c:591 hfsplus_delete_inode+0x154/0x200 hfsplus_unlink+0x414/0x6a0 fs/hfsplus/dir.c:405 hfsplus_rename+0xd0/0x1b0 fs/hfsplus/dir.c:547 vfs_rename+0x9e0/0xe80 fs/namei.c:4779 do_renameat2+0x980/0x1040 fs/namei.c:4930 __do_sys_renameat2 fs/namei.c:4963 [inline] __se_sys_renameat2 fs/namei.c:4960 [inline] __arm64_sys_renameat2+0xe0/0xfc fs/namei.c:4960 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&HFSPLUS_I(inode)->extents_lock); lock(&sbi->alloc_mutex); lock(&HFSPLUS_I(inode)->extents_lock); lock(&sbi->alloc_mutex); *** DEADLOCK *** 6 locks held by syz-executor.3/8280: #0: ffff0000d331c460 (sb_writers#15){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:393 #1: ffff000123e475c0 (&type->i_mutex_dir_key#9/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline] #1: ffff000123e475c0 (&type->i_mutex_dir_key#9/1){+.+.}-{3:3}, at: lock_rename+0xf0/0x18c fs/namei.c:2990 #2: ffff000123e41740 (&sb->s_type->i_mutex_key#27){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline] #2: ffff000123e41740 (&sb->s_type->i_mutex_key#27){+.+.}-{3:3}, at: lock_two_nondirectories+0xd4/0x120 fs/inode.c:1121 #3: ffff000123e46840 (&sb->s_type->i_mutex_key#27/4){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline] #3: ffff000123e46840 (&sb->s_type->i_mutex_key#27/4){+.+.}-{3:3}, at: lock_two_nondirectories+0xc4/0x120 fs/inode.c:1123 #4: ffff0000cb55a198 (&sbi->vh_mutex){+.+.}-{3:3}, at: hfsplus_unlink+0x144/0x6a0 fs/hfsplus/dir.c:370 #5: ffff000123e41548 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x250/0x9b8 fs/hfsplus/extents.c:576 stack backtrace: CPU: 0 PID: 8280 Comm: syz-executor.3 Not tainted 6.1.25-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023 Call trace: dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165 __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:2056 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2178 check_prev_add kernel/locking/lockdep.c:3098 [inline] check_prevs_add kernel/locking/lockdep.c:3217 [inline] validate_chain kernel/locking/lockdep.c:3832 [inline] __lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799 hfsplus_block_free+0xcc/0x4b0 fs/hfsplus/bitmap.c:182 hfsplus_free_extents+0x148/0x8d4 fs/hfsplus/extents.c:363 hfsplus_file_truncate+0x698/0x9b8 fs/hfsplus/extents.c:591 hfsplus_delete_inode+0x154/0x200 hfsplus_unlink+0x414/0x6a0 fs/hfsplus/dir.c:405 hfsplus_rename+0xd0/0x1b0 fs/hfsplus/dir.c:547 vfs_rename+0x9e0/0xe80 fs/namei.c:4779 do_renameat2+0x980/0x1040 fs/namei.c:4930 __do_sys_renameat2 fs/namei.c:4963 [inline] __se_sys_renameat2 fs/namei.c:4960 [inline] __arm64_sys_renameat2+0xe0/0xfc fs/namei.c:4960 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581