======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Tainted: G             L     
------------------------------------------------------
udevd/6016 is trying to acquire lock:
ffff8881105bfcc0 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}, at: process_measurement+0x7d0/0x1c10

but task is already holding lock:
ffff88810d8e6460 (sb_writers#5){.+.+}-{0:0}, at: mnt_want_write+0x41/0x90

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (sb_writers#5){.+.+}-{0:0}:
       sb_start_write+0x4d/0x1d0
       mnt_want_write+0x41/0x90
       lookup_open+0x1e6/0x1a40
       path_openat+0x677/0x1d60
       do_file_open+0x23e/0x4a0
       filp_open+0x16d/0x1d0
       fsg_lun_open+0x6c/0xdf0
       fsg_store_file+0x19e/0x400
       configfs_write_iter+0x337/0x430
       vfs_write+0x612/0xba0
       ksys_write+0x150/0x270
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #3 (&common->filesem){++++}-{4:4}:
       down_read+0x4a/0x330
       fsg_show_file+0x2d/0x140
       configfs_read_iter+0x2b7/0x620
       __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+0xe1/0x130
       security_file_post_open+0xb3/0x260
       path_openat+0x1485/0x1d60
       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 (&p->frag_sem){++++}-{4:4}:
       down_read+0x4a/0x330
       configfs_read_iter+0x1cc/0x620
       __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+0xe1/0x130
       security_file_post_open+0xb3/0x260
       path_openat+0x1485/0x1d60
       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 (&buffer->mutex#2){+.+.}-{4:4}:
       __mutex_lock+0x19d/0x1550
       configfs_read_iter+0x70/0x620
       __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+0xe1/0x130
       security_file_post_open+0xb3/0x260
       path_openat+0x1485/0x1d60
       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 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}:
       __lock_acquire+0x1520/0x2cf0
       lock_acquire+0x106/0x350
       __mutex_lock+0x19d/0x1550
       process_measurement+0x7d0/0x1c10
       ima_file_check+0xe1/0x130
       security_file_post_open+0xb3/0x260
       path_openat+0x1485/0x1d60
       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

other info that might help us debug this:

Chain exists of:
  &ima_iint_mutex_key[depth] --> &common->filesem --> sb_writers#5

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(sb_writers#5);
                               lock(&common->filesem);
                               lock(sb_writers#5);
  lock(&ima_iint_mutex_key[depth]);

 *** DEADLOCK ***

locks held by udevd/6016: 1, last CPU#0:
 #0: ffff88810d8e6460 (sb_writers#5){.+.+}-{0:0}, at: mnt_want_write+0x41/0x90

stack backtrace:
CPU: 0 UID: 0 PID: 6016 Comm: udevd Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
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+0x2e1/0x300
 check_noncircular+0x12e/0x150
 __lock_acquire+0x1520/0x2cf0
 lock_acquire+0x106/0x350
 __mutex_lock+0x19d/0x1550
 process_measurement+0x7d0/0x1c10
 ima_file_check+0xe1/0x130
 security_file_post_open+0xb3/0x260
 path_openat+0x1485/0x1d60
 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
RIP: 0033:0x7ff9a45169a4
Code: 24 20 48 8d 44 24 30 48 89 44 24 28 64 8b 04 25 18 00 00 00 85 c0 75 2c 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 76 60 48 8b 15 55 a4 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffd8e3e3d40 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ff9a45169a4
RDX: 00000000000a0241 RSI: 00007ffd8e3e49e8 RDI: 00000000ffffff9c
RBP: 00007ffd8e3e49e8 R08: 0000000000000000 R09: 000000000000000f
R10: 0000000000000124 R11: 0000000000000246 R12: 00000000000a0241
R13: 000055caa9c3d780 R14: 000055caa9c32d30 R15: 0000000000000001
 </TASK>
