======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Tainted: G S                 
------------------------------------------------------
syz.1.1824/20367 is trying to acquire lock:
ffff88811405f680 (&buffer->mutex){+.+.}-{4:4}, at: configfs_read_iter+0x70/0x620

but task is already holding lock:
ffff88802562d378 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}, at: process_measurement+0x7d0/0x1c10

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}:
       __mutex_lock+0x19d/0x1550
       ima_file_truncate+0xb6/0x170
       security_file_truncate+0x118/0x240
       path_openat+0x1569/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

-> #3 (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

-> #2 (&common->filesem){++++}-{4:4}:
       down_write+0x96/0x200
       fsg_store_file+0x163/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

-> #1 (&p->frag_sem){++++}-{4:4}:
       down_read+0x4a/0x330
       configfs_write_iter+0x238/0x430
       vfs_write+0x612/0xba0
       ksys_write+0x150/0x270
       do_syscall_64+0x166/0x520
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&buffer->mutex){+.+.}-{4:4}:
       __lock_acquire+0x164c/0x2de0
       lock_acquire+0x115/0x350
       __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

other info that might help us debug this:

Chain exists of:
  &buffer->mutex --> sb_writers#5 --> &ima_iint_mutex_key[depth]

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ima_iint_mutex_key[depth]);
                               lock(sb_writers#5);
                               lock(&ima_iint_mutex_key[depth]);
  lock(&buffer->mutex);

 *** DEADLOCK ***

locks held by syz.1.1824/20367: 1, last CPU#0:
 #0: ffff88802562d378 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}, at: process_measurement+0x7d0/0x1c10

stack backtrace:
CPU: 0 UID: 0 PID: 20367 Comm: syz.1.1824 Tainted: G S                  syzkaller #0 PREEMPT(full) 
Tainted: [S]=CPU_OUT_OF_SPEC
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
 __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
RIP: 0033:0x7f0fe539e559
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:00007f0fe623f028 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f0fe5625fa0 RCX: 00007f0fe539e559
RDX: 0000000000000002 RSI: 0000200000000540 RDI: ffffffffffffff9c
RBP: 00007f0fe54358b0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f0fe5626038 R14: 00007f0fe5625fa0 R15: 00007fff4a165848
 </TASK>
configfs: configfs_read_iter: count = 4096, pos = 0, buf = 3

configfs: configfs_read_iter: count = 4096, pos = 2, buf = 3

kcov: kcov_task_exit: t = ffff888109cfbc00, kcov->t = ffff888109cfbc00
ffff8880253e0000 name hci2 bus 0
hci2: Updating devcoredump state from IDLE to IDLE.
hci2: err 0x13
hci2 ffff8880253e0000
hci2: 
hci2: err 0x13
hci2: cancelling interleave scan
All LE pending actions cleared
hdev hci2
hcon ffff888021aa8000 reason 22
hcon ffff888021aa8000 conn ffff888024084000, err 103
hci2 hcon ffff888021aa8000 chan ffff88810ffbed00
hci2 hcon ffff888021aa8000 handle 200
hci2: hcon ffff888021aa8000
hcon ffff888021aa8000
hci2: conn ffff888021aa8000
device: 'hci2:200': device_unregister
kernfs runtime_status: removing
kernfs control: removing
kernfs runtime_suspended_time: removing
kernfs runtime_active_time: removing
kernfs autosuspend_delay_ms: removing
kernfs power: removing
kernfs device: removing
kernfs subsystem: removing
kernfs hci2:200: removing
kernfs uevent: removing
PM: Removing info for No Bus:hci2:200
kobject: 'hci2:200' (ffff888021aa8cf0): kobject_uevent_env
kobject: 'hci2:200' (ffff888021aa8cf0): fill_kobj_path: path = '/devices/virtual/bluetooth/hci2/hci2:200'
kernfs hci2:200: removing
kobject: 'hci2:200' (ffff888021aa8cf0): kobject_cleanup, parent 0000000000000000
kobject: 'hci2:200' (ffff888021aa8cf0): calling ktype release
kobject: 'hci2:200': free name
hci2 orig refcnt 11
hcon ffff888024680000 reason 22
hcon ffff888024680000 conn ffff888024082800, err 103
hci2 hcon ffff888024680000 chan ffff888102b15700
hci2 hcon ffff888024680000 handle 201
hci2: hcon ffff888024680000
hcon ffff888024680000
hci2: conn ffff888024680000
device: 'hci2:201': device_unregister
kernfs runtime_status: removing
kernfs control: removing
kernfs runtime_suspended_time: removing
kernfs runtime_active_time: removing
kernfs autosuspend_delay_ms: removing
kernfs power: removing
kernfs device: removing
kernfs subsystem: removing
kernfs hci2:201: removing
kernfs uevent: removing
PM: Removing info for No Bus:hci2:201
kobject: 'hci2:201' (ffff888024680cf0): kobject_uevent_env
kobject: 'hci2:201' (ffff888024680cf0): fill_kobj_path: path = '/devices/virtual/bluetooth/hci2/hci2:201'
kernfs hci2:201: removing
kobject: 'hci2:201' (ffff888024680cf0): kobject_cleanup, parent 0000000000000000
kobject: 'hci2:201' (ffff888024680cf0): calling ktype release
kobject: 'hci2:201': free name
hci2 orig refcnt 7
hdev hci2 event 4
hdev 0000000000000000 len 8
hci2: Cleanup of MSFT extension
hdev hci2 event 8
hci2 orig refcnt 6
channel 3 len 6
channel 3 len 8
hdev hci2 event 2
hdev 0000000000000000 len 8
kernfs runtime_status: removing
kernfs control: removing
kernfs runtime_suspended_time: removing
kernfs runtime_active_time: removing
kernfs autosuspend_delay_ms: removing
kernfs power: removing
kernfs device: removing
kernfs subsystem: removing
kernfs rfkill154: removing
kernfs uevent: removing
kernfs name: removing
kernfs type: removing
kernfs index: removing
kernfs persistent: removing
kernfs state: removing
kernfs soft: removing
kernfs hard: removing
kernfs hard_block_reasons: removing
PM: Removing info for No Bus:rfkill154
kobject: 'rfkill154' (ffff888113473110): kobject_uevent_env
kobject: 'rfkill154' (ffff888113473110): fill_kobj_path: path = '/devices/virtual/bluetooth/hci2/rfkill154'
kernfs rfkill154: removing
kobject: 'rfkill154' (ffff888113473110): kobject_cleanup, parent 0000000000000000
kobject: 'rfkill154' (ffff888113473110): calling ktype release
kobject: 'rfkill154': free name
kernfs runtime_status: removing
kernfs control: removing
kernfs runtime_suspended_time: removing
kernfs runtime_active_time: removing
kernfs autosuspend_delay_ms: removing
kernfs power: removing
kernfs subsystem: removing
kernfs hci2: removing
kernfs uevent: removing
kernfs reset: removing
PM: Removing info for No Bus:hci2
kobject: 'hci2' (ffff8880253e1538): kobject_uevent_env
kobject: 'hci2' (ffff8880253e1538): fill_kobj_path: path = '/devices/virtual/bluetooth/hci2'
kernfs hci2: removing
hci2 orig refcnt 2
kobject: 'hci2' (ffff8880253e1538): kobject_cleanup, parent 0000000000000000
kobject: 'hci2' (ffff8880253e1538): calling ktype release
All LE connection parameters were removed
hci2: Unregister MSFT extension
kobject: 'hci2': free name
syz_tun: bond_netdev_event received NETDEV_GOING_DOWN
net syz_tun: siw: event 10
In tnode_resize ffff88817213ba20 inflate_threshold=50 threshold=25
In tnode_resize ffff888171911820 inflate_threshold=50 threshold=25
In tnode_resize ffff88811f99f820 inflate_threshold=50 threshold=25
In tnode_resize ffff88802422ea20 inflate_threshold=50 threshold=25
In tnode_resize ffff888116fe12a0 inflate_threshold=50 threshold=25
In tnode_resize ffff888111b79120 inflate_threshold=50 threshold=25
In tnode_resize ffff888111b79620 inflate_threshold=50 threshold=25
trie_flush found=1
In tnode_resize ffff88817213ba20 inflate_threshold=50 threshold=25
In tnode_resize ffff888171911820 inflate_threshold=50 threshold=25
In tnode_resize ffff88811f99f820 inflate_threshold=50 threshold=25
In tnode_resize ffff88802422ea20 inflate_threshold=50 threshold=25
In tnode_resize ffff888116fe12a0 inflate_threshold=50 threshold=25
In tnode_resize ffff888111b79120 inflate_threshold=50 threshold=25
In tnode_resize ffff888111b79620 inflate_threshold=50 threshold=25
trie_flush found=1
syz_tun: bond_netdev_event received NETDEV_DOWN
net syz_tun: siw: event 2
IPv6: walker ffffc900041af1a0 adjusted by delroute
IPv6: walker ffffc900041af1a0 adjusted by delroute
IPv6: walker ffffc900041af1a0 adjusted by delroute
IPv6: fixing tree: plen=128 iter=0
IPv6: W ffffc900041af1a0 adjusted by delnode 1, s=4/2
IPv6: fixing tree: plen=120 iter=1
IPv6: W ffffc900041af1a0 adjusted by delnode 2, s=2
IPv6: fixing tree: plen=97 iter=2
IPv6: walker ffffc900041af1a0 adjusted by delroute
IPv6: fixing tree: plen=128 iter=0
IPv6: W ffffc900041af1a0 adjusted by delnode 1, s=4/2
IPv6: fixing tree: plen=120 iter=1
IPv6: W ffffc900041af1a0 adjusted by delnode 2, s=2
IPv6: fixing tree: plen=69 iter=2
IPv6: walker ffffc900041af1a0 adjusted by delroute
Deleting ac141400/24 dsfield=0x00 t=ffff888114f21030
Deleting ac1414ff/32 dsfield=0x00 t=ffff888114f21030
Deleting ac1414aa/32 dsfield=0x00 t=ffff888114f21030
In tnode_resize ffff88802422ea20 inflate_threshold=50 threshold=25
In tnode_resize ffff888111b79620 inflate_threshold=50 threshold=25
syz_tun (unregistering): bond_netdev_event received NETDEV_UNREGISTER
net syz_tun: siw: event 6
syz_tun (unregistering): bond_netdev_event received NETDEV_PRE_UNINIT
net syz_tun: siw: event 18
kernfs rps_cpus: removing
kernfs rps_flow_cnt: removing
kobject: 'rx-0' (ffff888027608e50): kobject_cleanup, parent ffff88816d5bf950
kobject: 'rx-0' (ffff888027608e50): auto cleanup kobject_del
kobject: 'rx-0' (ffff888027608e50): auto cleanup 'remove' event
kobject: 'rx-0' (ffff888027608e50): kobject_uevent_env
kobject: 'rx-0' (ffff888027608e50): fill_kobj_path: path = '/devices/virtual/net/syz_tun/queues/rx-0'
kernfs rx-0: removing
kobject: 'rx-0' (ffff888027608e50): calling ktype release
kobject: 'rx-0': free name
kernfs tx_timeout: removing
kernfs traffic_class: removing
kernfs xps_cpus: removing
kernfs xps_rxqs: removing
kernfs tx_maxrate: removing
kobject: 'tx-0' (ffff888114e5a420): kobject_cleanup, parent ffff88816d5bf950
kobject: 'tx-0' (ffff888114e5a420): auto cleanup kobject_del
kobject: 'tx-0' (ffff888114e5a420): auto cleanup 'remove' event
kobject: 'tx-0' (ffff888114e5a420): kobject_uevent_env
kobject: 'tx-0' (ffff888114e5a420): fill_kobj_path: path = '/devices/virtual/net/syz_tun/queues/tx-0'
kernfs tx-0: removing
kobject: 'tx-0' (ffff888114e5a420): calling ktype release
kobject: 'tx-0': free name
kernfs queues: removing
kobject: 'queues' (ffff88816d5bf950): kobject_cleanup, parent 0000000000000000
kobject: 'queues' (ffff88816d5bf950): calling ktype release
kobject: 'queues' (ffff88816d5bf950): kset_release
kobject: 'queues': free name
kernfs runtime_status: removing
kernfs control: removing
kernfs runtime_suspended_time: removing
kernfs runtime_active_time: removing
kernfs autosuspend_delay_ms: removing
kernfs power: removing
kernfs subsystem: removing
kernfs syz_tun: removing
kernfs uevent: removing
kernfs tun_flags: removing
kernfs owner: removing
kernfs group: removing
kernfs rx_packets: removing
kernfs tx_packets: removing
kernfs rx_bytes: removing
kernfs tx_bytes: removing
kernfs rx_errors: removing
kernfs tx_errors: removing
kernfs rx_dropped: removing
kernfs tx_dropped: removing
kernfs multicast: removing
kernfs collisions: removing
kernfs rx_length_errors: removing
kernfs rx_over_errors: removing
kernfs rx_crc_errors: removing
kernfs rx_frame_errors: removing
kernfs rx_fifo_errors: removing
kernfs rx_missed_errors: removing
kernfs tx_aborted_errors: removing
kernfs tx_carrier_errors: removing
kernfs tx_fifo_errors: removing
kernfs tx_heartbeat_errors: removing
kernfs tx_window_errors: removing
kernfs rx_compressed: removing
kernfs tx_compressed: removing
kernfs rx_nohandler: removing
kernfs statistics: removing
kernfs netdev_group: removing
kernfs type: removing
kernfs dev_id: removing
kernfs dev_port: removing
kernfs iflink: removing
kernfs ifindex: removing
kernfs name_assign_type: removing
kernfs addr_assign_type: removing
kernfs addr_len: removing
kernfs link_mode: removing
kernfs address: removing
kernfs broadcast: removing
kernfs speed: removing
kernfs duplex: removing
kernfs dormant: removing
kernfs testing: removing
kernfs operstate: removing
kernfs carrier_changes: removing
kernfs ifalias: removing
kernfs carrier: removing
kernfs mtu: removing
kernfs flags: removing
kernfs tx_queue_len: removing
kernfs gro_flush_timeout: removing
kernfs napi_defer_hard_irqs: removing
kernfs proto_down: removing
kernfs carrier_up_count: removing
kernfs carrier_down_count: removing
kernfs threaded: removing
PM: Removing info for No Bus:syz_tun
kobject: 'syz_tun' (ffff8880137887c0): kobject_uevent_env
kobject: 'syz_tun' (ffff8880137887c0): fill_kobj_path: path = '/devices/virtual/net/syz_tun'
kernfs syz_tun: removing
kobject: 'syz_tun' (ffff8880137887c0): kobject_cleanup, parent 0000000000000000
kobject: 'syz_tun' (ffff8880137887c0): calling ktype release
kobject: 'syz_tun': free name
