possible deadlock in uvcg_mjpeg_bma_controls_show

Status: upstream: reported on 2026/08/19 21:00
Reported-by: syzbot+758e11efdf4bc67fde72@syzkaller.appspotmail.com
First crash: 1d01h, last: 1d01h
Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in uvcg_mjpeg_bma_controls_show fs prio:high 4 11 4h25m 2d13h 0/29 upstream: reported on 2026/08/18 08:56

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.5.2363/13296 is trying to acquire lock:
ffffffff8cecf2f0 (gadget_subsys.su_mutex){+.+.}-{3:3}, at: uvcg_format_bma_controls_show drivers/usb/gadget/function/uvc_configfs.c:855 [inline]
ffffffff8cecf2f0 (gadget_subsys.su_mutex){+.+.}-{3:3}, at: uvcg_mjpeg_bma_controls_show+0x49/0x130 drivers/usb/gadget/function/uvc_configfs.c:1842

but task is already holding lock:
ffff8880228cdc78 (&p->frag_sem){++++}-{3:3}, at: fill_read_buffer fs/configfs/file.c:66 [inline]
ffff8880228cdc78 (&p->frag_sem){++++}-{3:3}, at: configfs_read_iter+0x19e/0x560 fs/configfs/file.c:88

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&p->frag_sem){++++}-{3:3}:
       down_write_killable+0x46/0x90 kernel/locking/rwsem.c:1562
       configfs_rmdir+0x3e0/0x980 fs/configfs/dir.c:1534
       vfs_rmdir+0x19d/0x410 fs/namei.c:4157
       do_rmdir+0x27f/0x710 fs/namei.c:4218
       __do_sys_unlinkat fs/namei.c:4398 [inline]
       __se_sys_unlinkat fs/namei.c:4392 [inline]
       __x64_sys_unlinkat+0xc0/0xe0 fs/namei.c:4392
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #2 (&sb->s_type->i_mutex_key#23){++++}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:787 [inline]
       configfs_depend_item_unlocked+0x14f/0x430 fs/configfs/dir.c:1255
       usbg_make_tpg+0x1f3/0x580 drivers/usb/gadget/function/f_tcm.c:1351
       target_fabric_make_tpg+0xa0/0x6d0 drivers/target/target_core_fabric_configfs.c:837
       configfs_mkdir+0x511/0x9e0 fs/configfs/dir.c:1360
       vfs_mkdir+0x386/0x570 fs/namei.c:4073
       do_mkdirat+0x1dd/0x5c0 fs/namei.c:4098
       __do_sys_mkdirat fs/namei.c:4113 [inline]
       __se_sys_mkdirat fs/namei.c:4111 [inline]
       __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4111
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #1 (&opts->dep_lock){+.+.}-{3:3}:
       __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       tcm_set_name+0x26/0x90 drivers/usb/gadget/function/f_tcm.c:2224
       function_make+0x195/0x350 drivers/usb/gadget/configfs.c:620
       configfs_mkdir+0x511/0x9e0 fs/configfs/dir.c:1360
       vfs_mkdir+0x386/0x570 fs/namei.c:4073
       do_mkdirat+0x1dd/0x5c0 fs/namei.c:4098
       __do_sys_mkdirat fs/namei.c:4113 [inline]
       __se_sys_mkdirat fs/namei.c:4111 [inline]
       __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4111
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (gadget_subsys.su_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3788 [inline]
       __lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
       lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       uvcg_format_bma_controls_show drivers/usb/gadget/function/uvc_configfs.c:855 [inline]
       uvcg_mjpeg_bma_controls_show+0x49/0x130 drivers/usb/gadget/function/uvc_configfs.c:1842
       fill_read_buffer fs/configfs/file.c:68 [inline]
       configfs_read_iter+0x296/0x560 fs/configfs/file.c:88
       __kernel_read+0x51d/0x980 fs/read_write.c:443
       integrity_kernel_read+0x86/0xd0 security/integrity/iint.c:228
       ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline]
       ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline]
       ima_calc_file_hash+0x946/0x1940 security/integrity/ima/ima_crypto.c:573
       ima_collect_measurement+0x335/0x7e0 security/integrity/ima/ima_api.c:255
       process_measurement+0x1185/0x1c20 security/integrity/ima/ima_main.c:351
       ima_file_check+0xc7/0x110 security/integrity/ima/ima_main.c:533
       do_open fs/namei.c:3618 [inline]
       path_openat+0x27cf/0x2fb0 fs/namei.c:3750
       do_filp_open+0x1df/0x400 fs/namei.c:3777
       do_sys_openat2+0x14b/0x500 fs/open.c:1255
       do_sys_open fs/open.c:1271 [inline]
       __do_sys_openat fs/open.c:1287 [inline]
       __se_sys_openat fs/open.c:1282 [inline]
       __x64_sys_openat+0x135/0x160 fs/open.c:1282
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Chain exists of:
  gadget_subsys.su_mutex --> &sb->s_type->i_mutex_key#23 --> &p->frag_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&p->frag_sem);
                               lock(&sb->s_type->i_mutex_key#23);
                               lock(&p->frag_sem);
  lock(gadget_subsys.su_mutex);

 *** DEADLOCK ***

3 locks held by syz.5.2363/13296:
 #0: ffff88807ea6eae8 (&iint_mutex_key[depth]){+.+.}-{3:3}, at: process_measurement+0x724/0x1c20 security/integrity/ima/ima_main.c:261
 #1: ffff888078e54088 (&buffer->mutex){+.+.}-{3:3}, at: configfs_read_iter+0x6e/0x560 fs/configfs/file.c:86
 #2: ffff8880228cdc78 (&p->frag_sem){++++}-{3:3}, at: fill_read_buffer fs/configfs/file.c:66 [inline]
 #2: ffff8880228cdc78 (&p->frag_sem){++++}-{3:3}, at: configfs_read_iter+0x19e/0x560 fs/configfs/file.c:88

stack backtrace:
CPU: 1 PID: 13296 Comm: syz.5.2363 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
 check_noncircular+0x296/0x330 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain kernel/locking/lockdep.c:3788 [inline]
 __lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
 lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
 __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
 uvcg_format_bma_controls_show drivers/usb/gadget/function/uvc_configfs.c:855 [inline]
 uvcg_mjpeg_bma_controls_show+0x49/0x130 drivers/usb/gadget/function/uvc_configfs.c:1842
 fill_read_buffer fs/configfs/file.c:68 [inline]
 configfs_read_iter+0x296/0x560 fs/configfs/file.c:88
 __kernel_read+0x51d/0x980 fs/read_write.c:443
 integrity_kernel_read+0x86/0xd0 security/integrity/iint.c:228
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline]
 ima_calc_file_hash+0x946/0x1940 security/integrity/ima/ima_crypto.c:573
 ima_collect_measurement+0x335/0x7e0 security/integrity/ima/ima_api.c:255
 process_measurement+0x1185/0x1c20 security/integrity/ima/ima_main.c:351
 ima_file_check+0xc7/0x110 security/integrity/ima/ima_main.c:533
 do_open fs/namei.c:3618 [inline]
 path_openat+0x27cf/0x2fb0 fs/namei.c:3750
 do_filp_open+0x1df/0x400 fs/namei.c:3777
 do_sys_openat2+0x14b/0x500 fs/open.c:1255
 do_sys_open fs/open.c:1271 [inline]
 __do_sys_openat fs/open.c:1287 [inline]
 __se_sys_openat fs/open.c:1282 [inline]
 __x64_sys_openat+0x135/0x160 fs/open.c:1282
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fadf9d6b0d9
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:00007fadf7fc3028 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007fadf9ff2fa0 RCX: 00007fadf9d6b0d9
RDX: 0000000000000002 RSI: 00002000000002c0 RDI: ffffffffffffff9c
RBP: 00007fadf9e02024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fadf9ff3038 R14: 00007fadf9ff2fa0 R15: 00007fff2a98d428
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/08/19 21:00 linux-5.15.y 0eb903b5b519 1e72964b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in uvcg_mjpeg_bma_controls_show
* Struck through repros no longer work on HEAD.