====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Tainted: G L ------------------------------------------------------ syz.1.1739/12210 is trying to acquire lock: ffff88804e588460 (sb_writers#5){.+.+}-{0:0}, at: lookup_open+0x150/0x1990 fs/namei.c:4451 but task is already holding lock: ffff888013c78920 (&common->filesem){++++}-{4:4}, at: fsg_store_file+0x193/0x450 drivers/usb/gadget/function/storage_common.c:452 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (&common->filesem){++++}-{4:4}: lock_acquire kernel/locking/lockdep.c:5908 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865 down_read+0x99/0x4c0 kernel/locking/rwsem.c:1574 fsg_store_cdrom+0xe2/0x190 drivers/usb/gadget/function/storage_common.c:478 flush_write_buffer fs/configfs/file.c:207 [inline] configfs_write_iter+0x302/0x4e0 fs/configfs/file.c:229 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #3 (&p->frag_sem){++++}-{4:4}: lock_acquire kernel/locking/lockdep.c:5908 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865 down_read+0x99/0x4c0 kernel/locking/rwsem.c:1574 flush_write_buffer fs/configfs/file.c:205 [inline] configfs_write_iter+0x218/0x4e0 fs/configfs/file.c:229 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #2 (&buffer->mutex){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5908 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x1a4/0x1bc0 kernel/locking/mutex.c:821 configfs_read_iter+0x79/0x6f0 fs/configfs/file.c:86 __kernel_read+0x397/0xad0 fs/read_write.c:532 integrity_kernel_read+0x7e/0xb0 security/integrity/iint.c:28 ima_calc_file_hash_tfm+0x25e/0x350 security/integrity/ima/ima_crypto.c:222 ima_calc_file_hash+0x1e3/0x380 security/integrity/ima/ima_crypto.c:280 ima_collect_measurement+0x94f/0xb30 security/integrity/ima/ima_api.c:300 process_measurement+0xdfe/0x2350 security/integrity/ima/ima_main.c:425 ima_file_check+0xcc/0x120 security/integrity/ima/ima_main.c:685 security_file_post_open+0xc4/0x210 security/security.c:2755 do_open fs/namei.c:4839 [inline] path_openat+0x5cd/0x2440 fs/namei.c:5000 do_file_open+0x20e/0x430 fs/namei.c:5029 do_sys_openat2+0x10f/0x1e0 fs/open.c:1417 do_sys_open fs/open.c:1423 [inline] __do_compat_sys_openat fs/open.c:1485 [inline] __se_compat_sys_openat fs/open.c:1483 [inline] __ia32_compat_sys_openat+0x12d/0x210 fs/open.c:1483 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #1 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5908 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x1a4/0x1bc0 kernel/locking/mutex.c:821 ima_reset_action_flags security/integrity/ima/ima_main.c:708 [inline] ima_reset_action_flags security/integrity/ima/ima_main.c:697 [inline] ima_file_truncate+0xe6/0x190 security/integrity/ima/ima_main.c:723 security_file_truncate+0x11e/0x1e0 security/security.c:2771 handle_truncate fs/namei.c:4298 [inline] do_open fs/namei.c:4841 [inline] path_openat+0x1d7e/0x2440 fs/namei.c:5000 do_file_open+0x20e/0x430 fs/namei.c:5029 do_sys_openat2+0x10f/0x1e0 fs/open.c:1417 do_sys_open fs/open.c:1423 [inline] __do_compat_sys_openat fs/open.c:1485 [inline] __se_compat_sys_openat fs/open.c:1483 [inline] __ia32_compat_sys_openat+0x12d/0x210 fs/open.c:1483 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #0 (sb_writers#5){.+.+}-{0:0}: check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3181 check_prevs_add kernel/locking/lockdep.c:3300 [inline] validate_chain kernel/locking/lockdep.c:3924 [inline] __lock_acquire+0x1492/0x1ec0 kernel/locking/lockdep.c:5254 lock_acquire kernel/locking/lockdep.c:5908 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs/super.h:19 [inline] sb_start_write include/linux/fs/super.h:125 [inline] mnt_want_write+0x6f/0x420 fs/namespace.c:494 lookup_open+0x150/0x1990 fs/namei.c:4451 open_last_lookups fs/namei.c:4767 [inline] path_openat+0xa2c/0x2440 fs/namei.c:4997 do_file_open+0x20e/0x430 fs/namei.c:5029 file_open_name+0x1c3/0x3e0 fs/open.c:1375 filp_open+0x2e/0x50 fs/open.c:1392 fsg_lun_open+0x6b/0x7b0 drivers/usb/gadget/function/storage_common.c:194 fsg_store_file+0x1e7/0x450 drivers/usb/gadget/function/storage_common.c:455 flush_write_buffer fs/configfs/file.c:207 [inline] configfs_write_iter+0x302/0x4e0 fs/configfs/file.c:229 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e other info that might help us debug this: Chain exists of: sb_writers#5 --> &p->frag_sem --> &common->filesem Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&common->filesem); lock(&p->frag_sem); lock(&common->filesem); rlock(sb_writers#5); *** DEADLOCK *** locks held by syz.1.1739/12210: 5, last CPU#3: #0: ffff88802adb1eb0 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x2aa/0x380 fs/file.c:1259 #1: ffff888022ac4460 (sb_writers#11){.+.+}-{0:0}, at: ksys_write+0x12a/0x250 fs/read_write.c:739 #2: ffff888021ea6280 (&buffer->mutex){+.+.}-{4:4}, at: configfs_write_iter+0x76/0x4e0 fs/configfs/file.c:226 #3: ffff8880730e1770 (&p->frag_sem){++++}-{4:4}, at: flush_write_buffer fs/configfs/file.c:205 [inline] #3: ffff8880730e1770 (&p->frag_sem){++++}-{4:4}, at: configfs_write_iter+0x218/0x4e0 fs/configfs/file.c:229 #4: ffff888013c78920 (&common->filesem){++++}-{4:4}, at: fsg_store_file+0x193/0x450 drivers/usb/gadget/function/storage_common.c:452 stack backtrace: CPU: 3 UID: 0 PID: 12210 Comm: syz.1.1739 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_circular_bug.cold+0x178/0x1be kernel/locking/lockdep.c:2059 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2191 check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3181 check_prevs_add kernel/locking/lockdep.c:3300 [inline] validate_chain kernel/locking/lockdep.c:3924 [inline] __lock_acquire+0x1492/0x1ec0 kernel/locking/lockdep.c:5254 lock_acquire kernel/locking/lockdep.c:5908 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs/super.h:19 [inline] sb_start_write include/linux/fs/super.h:125 [inline] mnt_want_write+0x6f/0x420 fs/namespace.c:494 lookup_open+0x150/0x1990 fs/namei.c:4451 open_last_lookups fs/namei.c:4767 [inline] path_openat+0xa2c/0x2440 fs/namei.c:4997 do_file_open+0x20e/0x430 fs/namei.c:5029 file_open_name+0x1c3/0x3e0 fs/open.c:1375 filp_open+0x2e/0x50 fs/open.c:1392 fsg_lun_open+0x6b/0x7b0 drivers/usb/gadget/function/storage_common.c:194 fsg_store_file+0x1e7/0x450 drivers/usb/gadget/function/storage_common.c:455 flush_write_buffer fs/configfs/file.c:207 [inline] configfs_write_iter+0x302/0x4e0 fs/configfs/file.c:229 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x13a/0x8b0 arch/x86/entry/syscall_32.c:291 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:316 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf6feefec Code: Unable to access opcode bytes at 0xf6feefc2. RSP: 002b:00000000f53dd50c EFLAGS: 00000292 ORIG_RAX: 0000000000000004 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00000000800003c0 RDX: 0000000000000002 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000292 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 mass_storage.0/lun.0: unable to open backing file: fi