possible deadlock in tcm_register_callback

Status: upstream: reported on 2026/08/17 21:23
Reported-by: syzbot+75ffc0b88b703e3ac0fe@syzkaller.appspotmail.com
First crash: 5d11h, last: 5d11h
Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in tcm_register_callback usb prio:low 4 4 3d14h 13d 0/29 upstream: reported on 2026/08/10 00:13

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.3.45/4498 is trying to acquire lock:
ffff88805739a120 (&opts->dep_lock){+.+.}-{3:3}, at: tcm_register_callback+0x1c/0x60 drivers/usb/gadget/function/f_tcm.c:2175

but task is already holding lock:
ffff88801ca73d78 (&p->frag_sem){++++}-{3:3}, at: flush_write_buffer fs/configfs/file.c:205 [inline]
ffff88801ca73d78 (&p->frag_sem){++++}-{3:3}, at: configfs_write_iter+0x20e/0x400 fs/configfs/file.c:229

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&p->frag_sem){++++}-{3:3}:
       down_write_killable+0x45/0x90 kernel/locking/rwsem.c:1584
       configfs_rmdir+0x3e0/0x980 fs/configfs/dir.c:1534
       vfs_rmdir+0x34e/0x4a0 fs/namei.c:4199
       do_rmdir+0x29a/0x5c0 fs/namei.c:4260
       __do_sys_unlinkat fs/namei.c:4440 [inline]
       __se_sys_unlinkat fs/namei.c:4434 [inline]
       __x64_sys_unlinkat+0xc0/0xe0 fs/namei.c:4434
       do_syscall_x64 arch/x86/entry/common.c:46 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #1 (&sb->s_type->i_mutex_key#22){++++}-{3:3}:
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:758 [inline]
       configfs_depend_item_unlocked+0x14f/0x430 fs/configfs/dir.c:1255
       usbg_make_tpg+0x1f3/0x580 drivers/usb/gadget/function/f_tcm.c:1365
       target_fabric_make_tpg+0xa0/0x6d0 drivers/target/target_core_fabric_configfs.c:905
       configfs_mkdir+0x511/0x9e0 fs/configfs/dir.c:1360
       vfs_mkdir+0x386/0x570 fs/namei.c:4114
       do_mkdirat+0x1d8/0x440 fs/namei.c:4139
       __do_sys_mkdirat fs/namei.c:4154 [inline]
       __se_sys_mkdirat fs/namei.c:4152 [inline]
       __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4152
       do_syscall_x64 arch/x86/entry/common.c:46 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&opts->dep_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3095 [inline]
       check_prevs_add kernel/locking/lockdep.c:3214 [inline]
       validate_chain kernel/locking/lockdep.c:3830 [inline]
       __lock_acquire+0x2d18/0x7c40 kernel/locking/lockdep.c:5063
       lock_acquire+0x1bb/0x4a0 kernel/locking/lockdep.c:5676
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x12d/0xae0 kernel/locking/mutex.c:747
       tcm_register_callback+0x1c/0x60 drivers/usb/gadget/function/f_tcm.c:2175
       usbg_attach drivers/usb/gadget/function/f_tcm.c:2199 [inline]
       usbg_enable_tpg+0x6b/0x110 drivers/usb/gadget/function/f_tcm.c:1503
       target_fabric_tpg_base_enable_store+0x15d/0x220 drivers/target/target_core_fabric_configfs.c:839
       flush_write_buffer fs/configfs/file.c:207 [inline]
       configfs_write_iter+0x30b/0x400 fs/configfs/file.c:229
       call_write_iter include/linux/fs.h:2265 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x482/0x9a0 fs/read_write.c:584
       ksys_write+0x14d/0x260 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:46 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Chain exists of:
  &opts->dep_lock --> &sb->s_type->i_mutex_key#22 --> &p->frag_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&p->frag_sem);
                               lock(&sb->s_type->i_mutex_key#22);
                               lock(&p->frag_sem);
  lock(&opts->dep_lock);

 *** DEADLOCK ***

4 locks held by syz.3.45/4498:
 #0: ffff888075f6a368 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2ae/0x360 fs/file.c:1038
 #1: ffff88801a386460 (sb_writers#15){.+.+}-{0:0}, at: vfs_write+0x270/0x9a0 fs/read_write.c:580
 #2: ffff88807fa58a88 (&buffer->mutex#2){+.+.}-{3:3}, at: configfs_write_iter+0x7d/0x400 fs/configfs/file.c:226
 #3: ffff88801ca73d78 (&p->frag_sem){++++}-{3:3}, at: flush_write_buffer fs/configfs/file.c:205 [inline]
 #3: ffff88801ca73d78 (&p->frag_sem){++++}-{3:3}, at: configfs_write_iter+0x20e/0x400 fs/configfs/file.c:229

stack backtrace:
CPU: 0 PID: 4498 Comm: syz.3.45 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/0x24e lib/dump_stack.c:106
 check_noncircular+0x296/0x330 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3095 [inline]
 check_prevs_add kernel/locking/lockdep.c:3214 [inline]
 validate_chain kernel/locking/lockdep.c:3830 [inline]
 __lock_acquire+0x2d18/0x7c40 kernel/locking/lockdep.c:5063
 lock_acquire+0x1bb/0x4a0 kernel/locking/lockdep.c:5676
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x12d/0xae0 kernel/locking/mutex.c:747
 tcm_register_callback+0x1c/0x60 drivers/usb/gadget/function/f_tcm.c:2175
 usbg_attach drivers/usb/gadget/function/f_tcm.c:2199 [inline]
 usbg_enable_tpg+0x6b/0x110 drivers/usb/gadget/function/f_tcm.c:1503
 target_fabric_tpg_base_enable_store+0x15d/0x220 drivers/target/target_core_fabric_configfs.c:839
 flush_write_buffer fs/configfs/file.c:207 [inline]
 configfs_write_iter+0x30b/0x400 fs/configfs/file.c:229
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x482/0x9a0 fs/read_write.c:584
 ksys_write+0x14d/0x260 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:46 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:76
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f6d0039e0d9
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:00007f6d01337028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f6d00625fa0 RCX: 00007f6d0039e0d9
RDX: 0000000000000002 RSI: 0000200000000480 RDI: 0000000000000006
RBP: 00007f6d00435024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f6d00626038 R14: 00007f6d00625fa0 R15: 00007ffc323a7ce8
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/08/17 21:22 linux-6.1.y e4f7d8be268e 905244d6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in tcm_register_callback
* Struck through repros no longer work on HEAD.