======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz-executor/4187 is trying to acquire lock:
ffff88802593b0f8 (&sbi->alloc_mutex){+.+.}-{3:3}, at: hfsplus_block_free+0xc1/0x4d0 fs/hfsplus/bitmap.c:182
but task is already holding lock:
ffff888024f50108 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x2c6/0xb80 fs/hfsplus/extents.c:574
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+0x1e3/0x2400 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
hfsplus_get_block+0x3a1/0x15a0 fs/hfsplus/extents.c:260
block_read_full_page+0x306/0xd40 fs/buffer.c:2290
do_read_cache_page+0x8a1/0x1030 mm/filemap.c:-1
read_mapping_page include/linux/pagemap.h:515 [inline]
hfsplus_block_allocate+0xf1/0x910 fs/hfsplus/bitmap.c:37
hfsplus_file_extend+0xb1f/0x1a50 fs/hfsplus/extents.c:466
hfsplus_get_block+0x430/0x15a0 fs/hfsplus/extents.c:245
__block_write_begin_int+0x565/0x15d0 fs/buffer.c:2012
__block_write_begin fs/buffer.c:2062 [inline]
block_write_begin fs/buffer.c:2122 [inline]
cont_write_begin+0x598/0x7b0 fs/buffer.c:2471
hfsplus_write_begin+0x92/0xe0 fs/hfsplus/inode.c:53
generic_perform_write+0x2b6/0x550 mm/filemap.c:3785
__generic_file_write_iter+0x25f/0x4e0 mm/filemap.c:3912
generic_file_write_iter+0xa6/0x1b0 mm/filemap.c:3944
__kernel_write+0x51c/0x970 fs/read_write.c:539
__dump_emit+0x249/0x370 fs/coredump.c:943
elf_core_dump+0x2757/0x3500 fs/binfmt_elf.c:2237
do_coredump+0x14c7/0x2ac0 fs/coredump.c:894
get_signal+0x410/0x12d0 kernel/signal.c:2886
arch_do_signal_or_restart+0xe7/0x12c0 arch/x86/kernel/signal.c:867
handle_signal_work kernel/entry/common.c:154 [inline]
exit_to_user_mode_loop+0x9e/0x130 kernel/entry/common.c:178
exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:214
__syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:307
do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x66/0xd0
-> #0 (&sbi->alloc_mutex){+.+.}-{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+0x2c42/0x7d10 kernel/locking/lockdep.c:5012
lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1e3/0x2400 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
hfsplus_block_free+0xc1/0x4d0 fs/hfsplus/bitmap.c:182
hfsplus_free_extents+0x10d/0xa50 fs/hfsplus/extents.c:360
hfsplus_file_truncate+0x783/0xb80 fs/hfsplus/extents.c:589
hfsplus_delete_inode+0x17c/0x230 fs/hfsplus/inode.c:-1
hfsplus_unlink+0x4f7/0x7b0 fs/hfsplus/dir.c:405
vfs_unlink+0x385/0x600 fs/namei.c:4288
do_unlinkat+0x391/0x710 fs/namei.c:4356
__do_sys_unlink fs/namei.c:4404 [inline]
__se_sys_unlink fs/namei.c:4402 [inline]
__x64_sys_unlink+0x45/0x50 fs/namei.c:4402
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
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 ***
5 locks held by syz-executor/4187:
#0: ffff888059de8460 (sb_writers#24){.+.+}-{0:0}, at: mnt_want_write+0x3d/0x90 fs/namespace.c:386
#1: ffff8880748b9e00 (&type->i_mutex_dir_key#16/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:822 [inline]
#1: ffff8880748b9e00 (&type->i_mutex_dir_key#16/1){+.+.}-{3:3}, at: do_unlinkat+0x1c8/0x710 fs/namei.c:4339
#2: ffff888024f50300 (&sb->s_type->i_mutex_key#30){++++}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
#2: ffff888024f50300 (&sb->s_type->i_mutex_key#30){++++}-{3:3}, at: vfs_unlink+0xee/0x600 fs/namei.c:4277
#3: ffff88802593b198 (&sbi->vh_mutex){+.+.}-{3:3}, at: hfsplus_unlink+0x175/0x7b0 fs/hfsplus/dir.c:370
#4: ffff888024f50108 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x2c6/0xb80 fs/hfsplus/extents.c:574
stack backtrace:
CPU: 0 PID: 4187 Comm: syz-executor Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
check_noncircular+0x296/0x330 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+0x2c42/0x7d10 kernel/locking/lockdep.c:5012
lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
__mutex_lock_common+0x1e3/0x2400 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
hfsplus_block_free+0xc1/0x4d0 fs/hfsplus/bitmap.c:182
hfsplus_free_extents+0x10d/0xa50 fs/hfsplus/extents.c:360
hfsplus_file_truncate+0x783/0xb80 fs/hfsplus/extents.c:589
hfsplus_delete_inode+0x17c/0x230 fs/hfsplus/inode.c:-1
hfsplus_unlink+0x4f7/0x7b0 fs/hfsplus/dir.c:405
vfs_unlink+0x385/0x600 fs/namei.c:4288
do_unlinkat+0x391/0x710 fs/namei.c:4356
__do_sys_unlink fs/namei.c:4404 [inline]
__se_sys_unlink fs/namei.c:4402 [inline]
__x64_sys_unlink+0x45/0x50 fs/namei.c:4402
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fc63fb52f47
Code: 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 57 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8
RSP: 002b:00007ffc3b686388 EFLAGS: 00000206 ORIG_RAX: 0000000000000057
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc63fb52f47
RDX: 00007ffc3b6863b0 RSI: 00007ffc3b686440 RDI: 00007ffc3b686440
RBP: 00007ffc3b686440 R08: 00007ffc3b687440 R09: 00000000ffffffff
R10: 0000000000000100 R11: 0000000000000206 R12: 00007ffc3b687530
R13: 00007fc63fbe91ca R14: 000000000001c7d7 R15: 00007ffc3b688600
</TASK>
hfsplus: unable to mark blocks free: error -5
hfsplus: can't free extent
hfsplus: unable to mark blocks free: error -5
hfsplus: can't free extent
hfsplus: unable to mark blocks free: error -5
hfsplus: can't free extent
hfsplus: invalid extended attribute record
hfsplus: unable to mark blocks free: error -5
hfsplus: can't free extent
hfsplus: unable to mark blocks free: error -5
hfsplus: can't free extent