======================================================
WARNING: possible circular locking dependency detected
4.19.211-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/12053 is trying to acquire lock:
00000000f266e65b (&HFSPLUS_I(inode)->extents_lock){+.+.}, at: hfsplus_file_extend+0x1bb/0xf40 fs/hfsplus/extents.c:457

but task is already holding lock:
0000000082bd0e29 (&tree->tree_lock){+.+.}, at: hfsplus_find_init+0x1b7/0x220 fs/hfsplus/bfind.c:30

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock){+.+.}:
       hfsplus_file_truncate+0xde7/0x1040 fs/hfsplus/extents.c:595
       hfsplus_setattr+0x1e7/0x310 fs/hfsplus/inode.c:263
       notify_change+0x70b/0xfc0 fs/attr.c:334
       do_truncate+0x134/0x1f0 fs/open.c:63
       handle_truncate fs/namei.c:3009 [inline]
       do_last fs/namei.c:3427 [inline]
       path_openat+0x2308/0x2df0 fs/namei.c:3537
       do_filp_open+0x18c/0x3f0 fs/namei.c:3567
       do_sys_open+0x3b3/0x520 fs/open.c:1085
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&HFSPLUS_I(inode)->extents_lock){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:937 [inline]
       __mutex_lock+0xd7/0x1190 kernel/locking/mutex.c:1078
       hfsplus_file_extend+0x1bb/0xf40 fs/hfsplus/extents.c:457
       hfsplus_bmap_reserve+0x298/0x440 fs/hfsplus/btree.c:357
       hfsplus_rename_cat+0x272/0x1490 fs/hfsplus/catalog.c:456
       hfsplus_unlink+0x49c/0x820 fs/hfsplus/dir.c:376
       vfs_unlink+0x27d/0x4e0 fs/namei.c:4002
       do_unlinkat+0x3b8/0x660 fs/namei.c:4065
       do_coredump+0x1f9c/0x2d60 fs/coredump.c:687
       get_signal+0xed9/0x1f70 kernel/signal.c:2583
       do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799
       exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
       prepare_exit_to_usermode+0x277/0x2d0 arch/x86/entry/common.c:198
       retint_user+0x8/0x18

other info that might help us debug this:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

5 locks held by syz-executor.1/12053:
 #0: 0000000079ec0b22 (sb_writers#20){.+.+}, at: sb_start_write include/linux/fs.h:1579 [inline]
 #0: 0000000079ec0b22 (sb_writers#20){.+.+}, at: mnt_want_write+0x3a/0xb0 fs/namespace.c:360
 #1: 00000000f499c3f9 (&type->i_mutex_dir_key#11/1){+.+.}, at: inode_lock_nested include/linux/fs.h:783 [inline]
 #1: 00000000f499c3f9 (&type->i_mutex_dir_key#11/1){+.+.}, at: do_unlinkat+0x27d/0x660 fs/namei.c:4051
 #2: 00000000de4a8044 (&sb->s_type->i_mutex_key#25){+.+.}, at: inode_lock include/linux/fs.h:748 [inline]
 #2: 00000000de4a8044 (&sb->s_type->i_mutex_key#25){+.+.}, at: vfs_unlink+0xca/0x4e0 fs/namei.c:3993
 #3: 0000000016233a68 (&sbi->vh_mutex){+.+.}, at: hfsplus_unlink+0x140/0x820 fs/hfsplus/dir.c:370
 #4: 0000000082bd0e29 (&tree->tree_lock){+.+.}, at: hfsplus_find_init+0x1b7/0x220 fs/hfsplus/bfind.c:30

stack backtrace:
CPU: 1 PID: 12053 Comm: syz-executor.1 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/2023
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1222
 check_prev_add kernel/locking/lockdep.c:1866 [inline]
 check_prevs_add kernel/locking/lockdep.c:1979 [inline]
 validate_chain kernel/locking/lockdep.c:2420 [inline]
 __lock_acquire+0x30c9/0x3ff0 kernel/locking/lockdep.c:3416
 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3908
 __mutex_lock_common kernel/locking/mutex.c:937 [inline]
 __mutex_lock+0xd7/0x1190 kernel/locking/mutex.c:1078
 hfsplus_file_extend+0x1bb/0xf40 fs/hfsplus/extents.c:457
 hfsplus_bmap_reserve+0x298/0x440 fs/hfsplus/btree.c:357
 hfsplus_rename_cat+0x272/0x1490 fs/hfsplus/catalog.c:456
 hfsplus_unlink+0x49c/0x820 fs/hfsplus/dir.c:376
 vfs_unlink+0x27d/0x4e0 fs/namei.c:4002
 do_unlinkat+0x3b8/0x660 fs/namei.c:4065
 do_coredump+0x1f9c/0x2d60 fs/coredump.c:687
 get_signal+0xed9/0x1f70 kernel/signal.c:2583
 do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799
 exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
 prepare_exit_to_usermode+0x277/0x2d0 arch/x86/entry/common.c:198
 retint_user+0x8/0x18
RIP: 0033:          (null)
Code: Bad RIP value.
RSP: 002b:0000000020000188 EFLAGS: 00010217
RAX: 0000000000000000 RBX: 00007f7c6551f050 RCX: 00007f7c653ff0f9
RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000000
RBP: 00007f7c6545aae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc407da43f R14: 00007f7c63950300 R15: 0000000000022000
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.
ntfs: volume version 3.1.