====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Tainted: G L ------------------------------------------------------ syz.2.629/8546 is trying to acquire lock: ffffffff916391a8 (gadget_subsys.su_mutex){+.+.}-{4:4}, at: uvcg_extension_ba_source_id_show+0x7c/0x310 drivers/usb/gadget/function/uvc_configfs.c:1018 but task is already holding lock: ffff8880533a1970 (&p->frag_sem){++++}-{4:4}, at: fill_read_buffer fs/configfs/file.c:66 [inline] ffff8880533a1970 (&p->frag_sem){++++}-{4:4}, at: configfs_read_iter+0x346/0x6f0 fs/configfs/file.c:88 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (&p->frag_sem){++++}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 down_write_killable+0x8e/0x240 kernel/locking/rwsem.c:1643 configfs_rmdir+0x3fa/0x950 fs/configfs/dir.c:1543 vfs_rmdir fs/namei.c:5533 [inline] vfs_rmdir+0x328/0x8e0 fs/namei.c:5506 filename_rmdir+0x31a/0x610 fs/namei.c:5590 __do_sys_unlinkat fs/namei.c:5765 [inline] __se_sys_unlinkat fs/namei.c:5758 [inline] __ia32_sys_unlinkat+0xf5/0x130 fs/namei.c:5758 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14d/0x8e0 arch/x86/entry/syscall_32.c:286 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #3 (&sb->s_type->i_mutex_key#29){++++}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 down_write+0x86/0x1f0 kernel/locking/rwsem.c:1631 inode_lock include/linux/fs.h:1027 [inline] configfs_depend_item_unlocked+0xf3/0x6a0 fs/configfs/dir.c:1268 usbg_make_tpg+0x251/0x610 drivers/usb/gadget/function/f_tcm.c:1692 target_fabric_make_tpg+0xab/0x8c0 drivers/target/target_core_fabric_configfs.c:947 configfs_mkdir+0x525/0xd40 fs/configfs/dir.c:1369 vfs_mkdir+0x36d/0x8a0 fs/namei.c:5428 filename_mkdirat+0x4c4/0x630 fs/namei.c:5461 __do_sys_mkdirat fs/namei.c:5482 [inline] __se_sys_mkdirat fs/namei.c:5479 [inline] __ia32_sys_mkdirat+0x88/0xc0 fs/namei.c:5479 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14d/0x8e0 arch/x86/entry/syscall_32.c:286 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #2 (tpg_instances_lock){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 tcm_alloc_inst+0x5f/0x1e0 drivers/usb/gadget/function/f_tcm.c:2687 try_get_usb_function_instance+0x136/0x1f0 drivers/usb/gadget/functions.c:28 usb_get_function_instance+0x16/0x70 drivers/usb/gadget/functions.c:44 function_make+0x18c/0x3f0 drivers/usb/gadget/configfs.c:626 configfs_mkdir+0x525/0xd40 fs/configfs/dir.c:1369 vfs_mkdir+0x36d/0x8a0 fs/namei.c:5428 filename_mkdirat+0x4c4/0x630 fs/namei.c:5461 __do_sys_mkdirat fs/namei.c:5482 [inline] __se_sys_mkdirat fs/namei.c:5479 [inline] __ia32_sys_mkdirat+0x88/0xc0 fs/namei.c:5479 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14d/0x8e0 arch/x86/entry/syscall_32.c:286 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #1 (func_lock){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 try_get_usb_function_instance+0x26/0x1f0 drivers/usb/gadget/functions.c:18 usb_get_function_instance+0x16/0x70 drivers/usb/gadget/functions.c:44 function_make+0x18c/0x3f0 drivers/usb/gadget/configfs.c:626 configfs_mkdir+0x525/0xd40 fs/configfs/dir.c:1369 vfs_mkdir+0x36d/0x8a0 fs/namei.c:5428 filename_mkdirat+0x4c4/0x630 fs/namei.c:5461 __do_sys_mkdirat fs/namei.c:5482 [inline] __se_sys_mkdirat fs/namei.c:5479 [inline] __ia32_sys_mkdirat+0x88/0xc0 fs/namei.c:5479 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14d/0x8e0 arch/x86/entry/syscall_32.c:286 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311 entry_SYSENTER_compat_after_hwframe+0x84/0x8e -> #0 (gadget_subsys.su_mutex){+.+.}-{4:4}: check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209 check_prevs_add kernel/locking/lockdep.c:3328 [inline] validate_chain kernel/locking/lockdep.c:3952 [inline] __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288 lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 uvcg_extension_ba_source_id_show+0x7c/0x310 drivers/usb/gadget/function/uvc_configfs.c:1018 fill_read_buffer fs/configfs/file.c:68 [inline] configfs_read_iter+0x426/0x6f0 fs/configfs/file.c:88 __kernel_read+0x397/0xac0 fs/read_write.c:512 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+0x167/0x380 security/integrity/ima/ima_crypto.c:280 ima_collect_measurement+0x952/0xb30 security/integrity/ima/ima_api.c:300 process_measurement+0xe04/0x2360 security/integrity/ima/ima_main.c:425 ima_file_check+0xc8/0x120 security/integrity/ima/ima_main.c:686 security_file_post_open+0xc4/0x210 security/security.c:2777 do_open fs/namei.c:4853 [inline] path_openat+0x5d0/0x23f0 fs/namei.c:5016 do_file_open+0x20e/0x430 fs/namei.c:5045 do_sys_openat2+0x163/0x1d0 fs/open.c:1443 do_sys_open fs/open.c:1449 [inline] __do_compat_sys_openat fs/open.c:1511 [inline] __se_compat_sys_openat fs/open.c:1509 [inline] __ia32_compat_sys_openat+0x12d/0x210 fs/open.c:1509 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14d/0x8e0 arch/x86/entry/syscall_32.c:286 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311 entry_SYSENTER_compat_after_hwframe+0x84/0x8e other info that might help us debug this: Chain exists of: gadget_subsys.su_mutex --> &sb->s_type->i_mutex_key#29 --> &p->frag_sem Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(&p->frag_sem); lock(&sb->s_type->i_mutex_key#29); lock(&p->frag_sem); lock(gadget_subsys.su_mutex); *** DEADLOCK *** locks held by syz.2.629/8546: 3, on CPU#2: #0: ffff888070fbbb30 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}, at: process_measurement+0x5ab/0x2360 security/integrity/ima/ima_main.c:319 #1: ffff88804de0ac80 (&buffer->mutex){+.+.}-{4:4}, at: configfs_read_iter+0x79/0x6f0 fs/configfs/file.c:86 #2: ffff8880533a1970 (&p->frag_sem){++++}-{4:4}, at: fill_read_buffer fs/configfs/file.c:66 [inline] #2: ffff8880533a1970 (&p->frag_sem){++++}-{4:4}, at: configfs_read_iter+0x346/0x6f0 fs/configfs/file.c:88 stack backtrace: CPU: 2 UID: 0 PID: 8546 Comm: syz.2.629 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:2087 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2219 check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209 check_prevs_add kernel/locking/lockdep.c:3328 [inline] validate_chain kernel/locking/lockdep.c:3952 [inline] __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288 lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 uvcg_extension_ba_source_id_show+0x7c/0x310 drivers/usb/gadget/function/uvc_configfs.c:1018 fill_read_buffer fs/configfs/file.c:68 [inline] configfs_read_iter+0x426/0x6f0 fs/configfs/file.c:88 __kernel_read+0x397/0xac0 fs/read_write.c:512 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+0x167/0x380 security/integrity/ima/ima_crypto.c:280 ima_collect_measurement+0x952/0xb30 security/integrity/ima/ima_api.c:300 process_measurement+0xe04/0x2360 security/integrity/ima/ima_main.c:425 ima_file_check+0xc8/0x120 security/integrity/ima/ima_main.c:686 security_file_post_open+0xc4/0x210 security/security.c:2777 do_open fs/namei.c:4853 [inline] path_openat+0x5d0/0x23f0 fs/namei.c:5016 do_file_open+0x20e/0x430 fs/namei.c:5045 do_sys_openat2+0x163/0x1d0 fs/open.c:1443 do_sys_open fs/open.c:1449 [inline] __do_compat_sys_openat fs/open.c:1511 [inline] __se_compat_sys_openat fs/open.c:1509 [inline] __ia32_compat_sys_openat+0x12d/0x210 fs/open.c:1509 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14d/0x8e0 arch/x86/entry/syscall_32.c:286 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf7f72fbc Code: d2 74 05 c1 e8 0c 89 02 8b 5d fc 31 c0 c9 c3 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 2e 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00 58 b8 RSP: 002b:00000000f542650c EFLAGS: 00000292 ORIG_RAX: 0000000000000127 RAX: ffffffffffffffda RBX: 00000000ffffff9c RCX: 00000000800004c0 RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000292 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 configfs: configfs_read_iter: count = 4096, pos = 0, buf = kcov: kcov_task_exit: t = ffff888048438000, kcov->t = ffff888048438000 ---------------- Code disassembly (best guess): 0: d2 74 05 c1 shlb %cl,-0x3f(%rbp,%rax,1) 4: e8 0c 89 02 8b call 0x8b028915 9: 5d pop %rbp a: fc cld b: 31 c0 xor %eax,%eax d: c9 leave e: c3 ret f: 90 nop 10: 90 nop 11: 90 nop 12: 90 nop 13: 90 nop 14: 90 nop 15: 90 nop 16: 90 nop 17: 90 nop 18: 90 nop 19: 90 nop 1a: 90 nop 1b: 90 nop 1c: 90 nop 1d: 90 nop 1e: 0f 1f 00 nopl (%rax) 21: 51 push %rcx 22: 52 push %rdx 23: 55 push %rbp 24: 89 e5 mov %esp,%ebp 26: 0f 34 sysenter 28: cd 80 int $0x80 * 2a: 5d pop %rbp <-- trapping instruction 2b: 5a pop %rdx 2c: 59 pop %rcx 2d: c3 ret 2e: 90 nop 2f: 2e 8d b4 26 00 00 00 cs lea 0x0(%rsi,%riz,1),%esi 36: 00 37: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi 3e: 58 pop %rax 3f: b8 .byte 0xb8