loop0: detected capacity change from 0 to 1024
======================================================
WARNING: possible circular locking dependency detected
6.1.100-syzkaller #0 Not tainted
------------------------------------------------------
syz.0.378/5430 is trying to acquire lock:
ffff88801f16f3c8 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_get_block+0x37f/0x14e0 fs/hfsplus/extents.c:260

but task is already holding lock:
ffff88801a2480b0 (&tree->tree_lock#2){+.+.}-{3:3}, at: hfsplus_find_init+0x146/0x1c0

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock#2){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       hfsplus_file_truncate+0x80d/0xb40 fs/hfsplus/extents.c:595
       hfsplus_setattr+0x1b9/0x280 fs/hfsplus/inode.c:269
       notify_change+0xce3/0xfc0 fs/attr.c:499
       do_truncate+0x21c/0x300 fs/open.c:65
       vfs_truncate+0x2dd/0x3a0 fs/open.c:111
       do_sys_truncate+0xda/0x190 fs/open.c:134
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       hfsplus_get_block+0x37f/0x14e0 fs/hfsplus/extents.c:260
       block_read_full_folio+0x403/0xf60 fs/buffer.c:2271
       filemap_read_folio+0x199/0x780 mm/filemap.c:2461
       do_read_cache_folio+0x2ee/0x810 mm/filemap.c:3598
       do_read_cache_page+0x32/0x220 mm/filemap.c:3640
       read_mapping_page include/linux/pagemap.h:791 [inline]
       __hfs_bnode_create+0x483/0x770 fs/hfsplus/bnode.c:440
       hfsplus_bnode_create+0x120/0x440 fs/hfsplus/bnode.c:576
       hfsplus_bmap_alloc+0x596/0x630 fs/hfsplus/btree.c:415
       hfs_btree_inc_height+0x11a/0xdb0 fs/hfsplus/brec.c:475
       hfsplus_brec_insert+0x776/0xdd0 fs/hfsplus/brec.c:148
       hfsplus_create_cat+0x498/0x1ba0 fs/hfsplus/catalog.c:292
       hfsplus_fill_super+0x13e6/0x1c90 fs/hfsplus/super.c:560
       mount_bdev+0x2c9/0x3f0 fs/super.c:1432
       legacy_get_tree+0xeb/0x180 fs/fs_context.c:632
       vfs_get_tree+0x88/0x270 fs/super.c:1562
       do_new_mount+0x2ba/0xb40 fs/namespace.c:3051
       do_mount fs/namespace.c:3394 [inline]
       __do_sys_mount fs/namespace.c:3602 [inline]
       __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3579
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&tree->tree_lock#2);
                               lock(&HFSPLUS_I(inode)->extents_lock);
                               lock(&tree->tree_lock#2);
  lock(&HFSPLUS_I(inode)->extents_lock);

 *** DEADLOCK ***

3 locks held by syz.0.378/5430:
 #0: ffff88801a24c0e0 (&type->s_umount_key#73/1){+.+.}-{3:3}, at: alloc_super+0x217/0x930 fs/super.c:228
 #1: ffff88814007a198 (&sbi->vh_mutex){+.+.}-{3:3}, at: hfsplus_fill_super+0x1378/0x1c90 fs/hfsplus/super.c:553
 #2: ffff88801a2480b0 (&tree->tree_lock#2){+.+.}-{3:3}, at: hfsplus_find_init+0x146/0x1c0

stack backtrace:
CPU: 1 PID: 5430 Comm: syz.0.378 Not tainted 6.1.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
 hfsplus_get_block+0x37f/0x14e0 fs/hfsplus/extents.c:260
 block_read_full_folio+0x403/0xf60 fs/buffer.c:2271
 filemap_read_folio+0x199/0x780 mm/filemap.c:2461
 do_read_cache_folio+0x2ee/0x810 mm/filemap.c:3598
 do_read_cache_page+0x32/0x220 mm/filemap.c:3640
 read_mapping_page include/linux/pagemap.h:791 [inline]
 __hfs_bnode_create+0x483/0x770 fs/hfsplus/bnode.c:440
 hfsplus_bnode_create+0x120/0x440 fs/hfsplus/bnode.c:576
 hfsplus_bmap_alloc+0x596/0x630 fs/hfsplus/btree.c:415
 hfs_btree_inc_height+0x11a/0xdb0 fs/hfsplus/brec.c:475
 hfsplus_brec_insert+0x776/0xdd0 fs/hfsplus/brec.c:148
 hfsplus_create_cat+0x498/0x1ba0 fs/hfsplus/catalog.c:292
 hfsplus_fill_super+0x13e6/0x1c90 fs/hfsplus/super.c:560
 mount_bdev+0x2c9/0x3f0 fs/super.c:1432
 legacy_get_tree+0xeb/0x180 fs/fs_context.c:632
 vfs_get_tree+0x88/0x270 fs/super.c:1562
 do_new_mount+0x2ba/0xb40 fs/namespace.c:3051
 do_mount fs/namespace.c:3394 [inline]
 __do_sys_mount fs/namespace.c:3602 [inline]
 __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3579
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f247eb7725a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 7e 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007f247fa34e78 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f247fa34f00 RCX: 00007f247eb7725a
RDX: 0000000020000000 RSI: 0000000020000080 RDI: 00007f247fa34ec0
RBP: 0000000020000000 R08: 00007f247fa34f00 R09: 0000000002000010
R10: 0000000002000010 R11: 0000000000000206 R12: 0000000020000080
R13: 00007f247fa34ec0 R14: 00000000000006a2 R15: 00000000200013c0
 </TASK>