bcachefs: bch2_fs_get_tree() error: EIO
overlayfs: failed to create directory ./bus/work (errno: 22); mounting read-only
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.2.5210/12033 is trying to acquire lock:
ffff888104dc4420 (sb_writers#9){.+.+}-{0:0}, at: mnt_want_write+0x41/0x90

but task is already holding lock:
ffff888110f04bc0 (&ovl_i_mutex_dir_key[depth]){++++}-{4:4}, at: path_openat+0x8cb/0x3830

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ovl_i_mutex_dir_key[depth]){++++}-{4:4}:
       lock_acquire+0x120/0x360
       down_read+0x46/0x2e0
       lookup_slow+0x46/0x70
       walk_component+0x2d2/0x400
       path_lookupat+0x163/0x430
       filename_lookup+0x212/0x570
       kern_path+0x35/0x50
       lookup_bdev+0xc0/0x280
       resume_store+0x169/0x460
       kernfs_fop_write_iter+0x3af/0x540
       vfs_write+0x5c9/0xb30
       ksys_write+0x145/0x250
       do_syscall_64+0xfa/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&of->mutex){+.+.}-{4:4}:
       lock_acquire+0x120/0x360
       __mutex_lock+0x187/0x1350
       kernfs_fop_write_iter+0x1de/0x540
       vfs_write+0x5c9/0xb30
       ksys_write+0x145/0x250
       do_syscall_64+0xfa/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (sb_writers#9){.+.+}-{0:0}:
       validate_chain+0xb9b/0x2140
       __lock_acquire+0xab9/0xd20
       lock_acquire+0x120/0x360
       sb_start_write+0x4d/0x1c0
       mnt_want_write+0x41/0x90
       ovl_lookup+0xaf6/0x1bc0
       path_openat+0x1101/0x3830
       do_filp_open+0x1fa/0x410
       do_sys_openat2+0x121/0x1c0
       __x64_sys_open+0x11e/0x150
       do_syscall_64+0xfa/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  sb_writers#9 --> &of->mutex --> &ovl_i_mutex_dir_key[depth]

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&ovl_i_mutex_dir_key[depth]);
                               lock(&of->mutex);
                               lock(&ovl_i_mutex_dir_key[depth]);
  rlock(sb_writers#9);

 *** DEADLOCK ***

1 lock held by syz.2.5210/12033:
 #0: ffff888110f04bc0 (&ovl_i_mutex_dir_key[depth]){++++}-{4:4}, at: path_openat+0x8cb/0x3830

stack backtrace:
CPU: 1 UID: 0 PID: 12033 Comm: syz.2.5210 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+0x189/0x250
 print_circular_bug+0x2ee/0x310
 check_noncircular+0x134/0x160
 validate_chain+0xb9b/0x2140
 __lock_acquire+0xab9/0xd20
 lock_acquire+0x120/0x360
 sb_start_write+0x4d/0x1c0
 mnt_want_write+0x41/0x90
 ovl_lookup+0xaf6/0x1bc0
 path_openat+0x1101/0x3830
 do_filp_open+0x1fa/0x410
 do_sys_openat2+0x121/0x1c0
 __x64_sys_open+0x11e/0x150
 do_syscall_64+0xfa/0xfa0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7ff77d78eba9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ff77e653038 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 00007ff77d9d5fa0 RCX: 00007ff77d78eba9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000200000000600
RBP: 00007ff77d811e19 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ff77d9d6038 R14: 00007ff77d9d5fa0 R15: 00007fff4799ccf8
 </TASK>
fuse: Bad value for 'fd'
