======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/u10:1/36 is trying to acquire lock:
ffff88816ce0c1f8 (&HFS_I(tree->inode)->extents_lock){+.+.}-{4:4}, at: hfs_extend_file+0xda/0x1540

but task is already holding lock:
ffff8881017e00b0 (&tree->tree_lock/1){+.+.}-{4:4}, at: hfs_find_init+0x18e/0x300

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock/1){+.+.}-{4:4}:
       __mutex_lock+0x187/0x1350
       hfs_find_init+0x18e/0x300
       hfs_extend_file+0x2f6/0x1540
       hfs_bmap_reserve+0x107/0x430
       hfs_cat_create+0x1c5/0x770
       hfs_create+0x66/0xe0
       vfs_create+0x3aa/0x400
       do_mknodat+0x3ea/0x610
       __x64_sys_mknodat+0xa7/0xc0
       do_syscall_64+0xfa/0xf80
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&HFS_I(tree->inode)->extents_lock){+.+.}-{4:4}:
       __lock_acquire+0x15a6/0x2cf0
       lock_acquire+0x117/0x340
       __mutex_lock+0x187/0x1350
       hfs_extend_file+0xda/0x1540
       hfs_bmap_reserve+0x107/0x430
       __hfs_ext_write_extent+0x1fa/0x470
       hfs_ext_write_extent+0x161/0x1e0
       hfs_write_inode+0xc6/0x8a0
       __writeback_single_inode+0x7e1/0x1240
       writeback_sb_inodes+0x93a/0x1870
       wb_writeback+0x42b/0xaa0
       wb_workfn+0x3f9/0xed0
       process_scheduled_works+0xad1/0x1770
       worker_thread+0x8a0/0xda0
       kthread+0x711/0x8a0
       ret_from_fork+0x599/0xb30
       ret_from_fork_asm+0x1a/0x30

other info that might help us debug this:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

3 locks held by kworker/u10:1/36:
 #0: ffff888103ec8948 ((wq_completion)writeback){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x1770
 #1: ffffc90000ac7b80 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x1770
 #2: ffff8881017e00b0 (&tree->tree_lock/1){+.+.}-{4:4}, at: hfs_find_init+0x18e/0x300

stack backtrace:
CPU: 1 UID: 0 PID: 36 Comm: kworker/u10:1 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
Workqueue: writeback wb_workfn (flush-7:7)
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250
 print_circular_bug+0x2e2/0x300
 check_noncircular+0x12e/0x150
 __lock_acquire+0x15a6/0x2cf0
 lock_acquire+0x117/0x340
 __mutex_lock+0x187/0x1350
 hfs_extend_file+0xda/0x1540
 hfs_bmap_reserve+0x107/0x430
 __hfs_ext_write_extent+0x1fa/0x470
 hfs_ext_write_extent+0x161/0x1e0
 hfs_write_inode+0xc6/0x8a0
 __writeback_single_inode+0x7e1/0x1240
 writeback_sb_inodes+0x93a/0x1870
 wb_writeback+0x42b/0xaa0
 wb_workfn+0x3f9/0xed0
 process_scheduled_works+0xad1/0x1770
 worker_thread+0x8a0/0xda0
 kthread+0x711/0x8a0
 ret_from_fork+0x599/0xb30
 ret_from_fork_asm+0x1a/0x30
 </TASK>
hfs: new node 0 already hashed?
------------[ cut here ]------------
WARNING: fs/hfs/bnode.c:520 at hfs_bnode_create+0x461/0x4f0, CPU#1: kworker/u10:1/36
Modules linked in:
CPU: 1 UID: 0 PID: 36 Comm: kworker/u10:1 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
Workqueue: writeback wb_workfn (flush-7:7)
RIP: 0010:hfs_bnode_create+0x461/0x4f0
Code: 82 8b 89 ee e8 20 b1 85 fe e9 cf fc ff ff e8 e6 b7 1f ff 4c 89 ef e8 fe a4 bb 08 48 c7 c7 00 b7 82 8b 89 ee e8 00 b1 85 fe 90 <0f> 0b 90 eb b0 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c d6 fb ff ff
RSP: 0018:ffffc90000ac6be0 EFLAGS: 00010246
RAX: 000000000000001f RBX: ffff8881017e0000 RCX: 86513e2cbe416d00
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000003 R09: 0000000000000004
R10: dffffc0000000000 R11: fffffbfff1bbae28 R12: 0000000000000000
R13: ffff8881017e00e0 R14: ffff8881b3626700 R15: dffffc0000000000
FS:  0000000000000000(0000) GS:ffff8882a9e3a000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffe140b7b38 CR3: 00000001a3208000 CR4: 00000000000006f0
Call Trace:
 <TASK>
 hfs_bmap_alloc+0x5bb/0x640
 hfs_btree_inc_height+0xf6/0xac0
 hfs_brec_insert+0x7ee/0xc80
 __hfs_ext_write_extent+0x2a1/0x470
 hfs_ext_write_extent+0x161/0x1e0
 hfs_write_inode+0xc6/0x8a0
 __writeback_single_inode+0x7e1/0x1240
 writeback_sb_inodes+0x93a/0x1870
 wb_writeback+0x42b/0xaa0
 wb_workfn+0x3f9/0xed0
 process_scheduled_works+0xad1/0x1770
 worker_thread+0x8a0/0xda0
 kthread+0x711/0x8a0
 ret_from_fork+0x599/0xb30
 ret_from_fork_asm+0x1a/0x30
 </TASK>
