======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.3.469/9418 is trying to acquire lock:
ffff88811afbc0a8 (&tree->tree_lock/1){+.+.}-{4:4}, at: hfs_find_init+0x18d/0x300

but task is already holding lock:
ffff88811aad42a0 (&HFS_I(tree->inode)->extents_lock){+.+.}-{4:4}, at: hfs_extend_file+0xf9/0x1680

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&HFS_I(tree->inode)->extents_lock){+.+.}-{4:4}:
       __mutex_lock+0x19d/0x1550
       hfs_extend_file+0xf9/0x1680
       hfs_bmap_reserve+0x108/0x430
       __hfs_ext_write_extent+0x1fc/0x470
       hfs_ext_write_extent+0x17d/0x210
       hfs_write_inode+0x117/0xa00
       __writeback_single_inode+0x69d/0x1220
       writeback_single_inode+0x544/0xf70
       write_inode_now+0x1c2/0x290
       hfs_file_fsync+0xa4/0x140
       generic_file_write_iter+0x280/0x330
       iter_file_splice_write+0xa31/0x1240
       direct_splice_actor+0x101/0x160
       splice_direct_to_actor+0x57b/0xcb0
       do_splice_direct+0x195/0x290
       do_sendfile+0x52e/0x7c0
       __se_sys_sendfile64+0x144/0x1a0
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&tree->tree_lock/1){+.+.}-{4:4}:
       __lock_acquire+0x15ff/0x2e50
       lock_acquire+0x115/0x350
       __mutex_lock+0x19d/0x1550
       hfs_find_init+0x18d/0x300
       hfs_extend_file+0x367/0x1680
       hfs_bmap_reserve+0x108/0x430
       hfs_cat_create+0x23d/0x870
       hfs_create+0x78/0xe0
       lookup_open+0xc0d/0x1a40
       path_openat+0x677/0x1d60
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x115/0x200
       __x64_sys_open+0x11e/0x150
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&HFS_I(tree->inode)->extents_lock);
                               lock(&tree->tree_lock/1);
                               lock(&HFS_I(tree->inode)->extents_lock);
  lock(&tree->tree_lock/1);

 *** DEADLOCK ***

locks held by syz.3.469/9418: 4, last CPU#1:
 #0: ffff88810a9c8460 (sb_writers#18){.+.+}-{0:0}, at: mnt_want_write+0x41/0x90
 #1: ffff88811aad3e40 (&type->i_mutex_dir_key#13){++++}-{4:4}, at: lookup_open+0x242/0x1a40
 #2: ffff88811b3e00a8 (&tree->tree_lock){+.+.}-{4:4}, at: hfs_find_init+0x18d/0x300
 #3: ffff88811aad42a0 (&HFS_I(tree->inode)->extents_lock){+.+.}-{4:4}, at: hfs_extend_file+0xf9/0x1680

stack backtrace:
CPU: 1 UID: 0 PID: 9418 Comm: syz.3.469 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150
 print_circular_bug+0x2e2/0x300
 check_noncircular+0x12f/0x150
 __lock_acquire+0x15ff/0x2e50
 lock_acquire+0x115/0x350
 __mutex_lock+0x19d/0x1550
 hfs_find_init+0x18d/0x300
 hfs_extend_file+0x367/0x1680
 hfs_bmap_reserve+0x108/0x430
 hfs_cat_create+0x23d/0x870
 hfs_create+0x78/0xe0
 lookup_open+0xc0d/0x1a40
 path_openat+0x677/0x1d60
 do_file_open+0x23e/0x4a0
 do_sys_openat2+0x115/0x200
 __x64_sys_open+0x11e/0x150
 do_syscall_64+0x166/0x520
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f87a2d9e159
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f87a3ca4028 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 00007f87a3025fa0 RCX: 00007f87a2d9e159
RDX: 0000000000000176 RSI: 00000000001ad941 RDI: 0000200000000100
RBP: 00007f87a2e3506b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f87a3026038 R14: 00007f87a3025fa0 R15: 00007ffe32f5e058
 </TASK>
