======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.9.934/16050 is trying to acquire lock:
ffff888023862d20 (&ovl_i_mutex_dir_key[depth]){++++}-{4:4}, at: lookup_slow+0x46/0x80

but task is already holding lock:
ffff88810add8480 (&of->mutex){+.+.}-{4:4}, at: kernfs_fop_write_iter+0x1d8/0x540

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&of->mutex){+.+.}-{4:4}:
       __mutex_lock+0x197/0x15a0
       kernfs_seq_start+0x5d/0x420
       seq_read_iter+0x37e/0xca0
       __kernel_read+0x4ca/0x960
       integrity_kernel_read+0x89/0xd0
       ima_calc_file_hash+0x451/0x890
       ima_collect_measurement+0x51b/0xa00
       process_measurement+0x1272/0x1c10
       ima_file_check+0xdc/0x130
       security_file_post_open+0xb3/0x260
       path_openat+0x1748/0x20f0
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x115/0x200
       __x64_sys_openat+0x138/0x170
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #3 (&p->lock){+.+.}-{4:4}:
       __mutex_lock+0x197/0x15a0
       seq_read_iter+0xa4/0xca0
       __kernel_read+0x4ca/0x960
       integrity_kernel_read+0x89/0xd0
       ima_calc_file_hash+0x451/0x890
       ima_collect_measurement+0x51b/0xa00
       process_measurement+0x1272/0x1c10
       ima_file_check+0xdc/0x130
       security_file_post_open+0xb3/0x260
       path_openat+0x1748/0x20f0
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x115/0x200
       __x64_sys_openat+0x138/0x170
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}:
       __mutex_lock+0x197/0x15a0
       process_measurement+0x7d0/0x1c10
       ima_file_check+0xdc/0x130
       security_file_post_open+0xb3/0x260
       path_openat+0x1748/0x20f0
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x115/0x200
       __x64_sys_openat+0x138/0x170
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (sb_writers#5){.+.+}-{0:0}:
       sb_start_write+0x48/0x1c0
       mnt_want_write+0x41/0x90
       ovl_create_object+0x10d/0x3b0
       lookup_open+0x102d/0x1ae0
       path_openat+0x70c/0x20f0
       do_file_open+0x23e/0x4a0
       do_sys_openat2+0x115/0x200
       __x64_sys_openat+0x138/0x170
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&ovl_i_mutex_dir_key[depth]){++++}-{4:4}:
       __lock_acquire+0x164c/0x2de0
       lock_acquire+0x115/0x350
       down_read+0x45/0x320
       lookup_slow+0x46/0x80
       path_lookupat+0x3f5/0x8c0
       filename_lookup+0x265/0x5d0
       kern_path+0x3d/0x150
       lookup_bdev+0xc8/0x2b0
       resume_store+0x181/0x500
       kernfs_fop_write_iter+0x3a4/0x540
       vfs_write+0x612/0xba0
       ksys_write+0x150/0x270
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &ovl_i_mutex_dir_key[depth] --> &p->lock --> &of->mutex

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

locks held by syz.9.934/16050: 4, last CPU#0:
 #0: ffff8880349254f0 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x118/0x160
 #1: ffff8881160fe478 (sb_writers#7){.+.+}-{0:0}, at: vfs_write+0x22b/0xba0
 #2: ffff88810add8480 (&of->mutex){+.+.}-{4:4}, at: kernfs_fop_write_iter+0x1d8/0x540
 #3: ffff8881616c05a8 (kn->active#86){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x22b/0x540

stack backtrace:
CPU: 0 UID: 0 PID: 16050 Comm: syz.9.934 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+0x164c/0x2de0
 lock_acquire+0x115/0x350
 down_read+0x45/0x320
 lookup_slow+0x46/0x80
 path_lookupat+0x3f5/0x8c0
 filename_lookup+0x265/0x5d0
 kern_path+0x3d/0x150
 lookup_bdev+0xc8/0x2b0
 resume_store+0x181/0x500
 kernfs_fop_write_iter+0x3a4/0x540
 vfs_write+0x612/0xba0
 ksys_write+0x150/0x270
 do_syscall_64+0x166/0x520
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f97c8d9f559
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:00007f97c9d0a028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f97c9025fa0 RCX: 00007f97c8d9f559
RDX: 0000000000000012 RSI: 000020000000cec0 RDI: 0000000000000003
RBP: 00007f97c8e36b20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f97c9026038 R14: 00007f97c9025fa0 R15: 00007ffe0ae0e818
 </TASK>
PM: hibernation: Configured hibernation resume from disk to 4194305
PM: hibernation: Hibernation image partition 4:1 present
PM: hibernation: Looking for hibernation image.
PM: Image not found (code -6)
PM: hibernation: Hibernation image not present or could not be loaded.
kcov: kcov_task_exit: t = ffff88810ecb8000, kcov->t = ffff88810ecb8000
