====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Not tainted ------------------------------------------------------ syz.2.623/8499 is trying to acquire lock: ffffffff8ddf6c50 (gadget_subsys.su_mutex){+.+.}-{3:3}, at: uvcg_frame_dw_max_video_frame_buffer_size_store+0x115/0x370 drivers/usb/gadget/function/uvc_configfs.c:2023 but task is already holding lock: ffff888022e0c578 (&p->frag_sem){++++}-{3:3}, at: flush_write_buffer fs/configfs/file.c:205 [inline] ffff888022e0c578 (&p->frag_sem){++++}-{3:3}, at: configfs_write_iter+0x215/0x400 fs/configfs/file.c:229 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+0xa7/0x230 kernel/locking/rwsem.c:1584 configfs_rmdir+0x3e4/0x980 fs/configfs/dir.c:1534 vfs_rmdir+0x352/0x4b0 fs/namei.c:4251 do_rmdir+0x29f/0x590 fs/namei.c:4310 __do_sys_unlinkat fs/namei.c:4488 [inline] __se_sys_unlinkat fs/namei.c:4482 [inline] __x64_sys_unlinkat+0xc4/0xe0 fs/namei.c:4482 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x68/0xd2 -> #2 (&sb->s_type->i_mutex_key#26){++++}-{3:3}: down_write+0x97/0x200 kernel/locking/rwsem.c:1573 inode_lock include/linux/fs.h:804 [inline] configfs_depend_item_unlocked+0x157/0x430 fs/configfs/dir.c:1255 usbg_make_tpg+0x1f7/0x580 drivers/usb/gadget/function/f_tcm.c:1341 target_fabric_make_tpg+0xa4/0x6d0 drivers/target/target_core_fabric_configfs.c:939 configfs_mkdir+0x515/0x9e0 fs/configfs/dir.c:1360 vfs_mkdir+0x2a5/0x470 fs/namei.c:4168 do_mkdirat+0x1dc/0x450 fs/namei.c:4191 __do_sys_mkdir fs/namei.c:4211 [inline] __se_sys_mkdir fs/namei.c:4209 [inline] __x64_sys_mkdir+0x6e/0x80 fs/namei.c:4209 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x68/0xd2 -> #1 (&opts->dep_lock){+.+.}-{3:3}: __mutex_lock_common kernel/locking/mutex.c:603 [inline] __mutex_lock+0x135/0xc80 kernel/locking/mutex.c:747 tcm_set_name+0x2a/0x90 drivers/usb/gadget/function/f_tcm.c:2317 function_make+0x199/0x350 drivers/usb/gadget/configfs.c:635 configfs_mkdir+0x515/0x9e0 fs/configfs/dir.c:1360 vfs_mkdir+0x2a5/0x470 fs/namei.c:4168 do_mkdirat+0x1dc/0x450 fs/namei.c:4191 __do_sys_mkdir fs/namei.c:4211 [inline] __se_sys_mkdir fs/namei.c:4209 [inline] __x64_sys_mkdir+0x6e/0x80 fs/namei.c:4209 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x68/0xd2 -> #0 (gadget_subsys.su_mutex){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:3134 [inline] check_prevs_add kernel/locking/lockdep.c:3253 [inline] validate_chain kernel/locking/lockdep.c:3869 [inline] __lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137 lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754 __mutex_lock_common kernel/locking/mutex.c:603 [inline] __mutex_lock+0x135/0xc80 kernel/locking/mutex.c:747 uvcg_frame_dw_max_video_frame_buffer_size_store+0x115/0x370 drivers/usb/gadget/function/uvc_configfs.c:2023 flush_write_buffer fs/configfs/file.c:207 [inline] configfs_write_iter+0x312/0x400 fs/configfs/file.c:229 call_write_iter include/linux/fs.h:2018 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x474/0x9a0 fs/read_write.c:584 ksys_write+0x151/0x260 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x68/0xd2 other info that might help us debug this: Chain exists of: gadget_subsys.su_mutex --> &sb->s_type->i_mutex_key#26 --> &p->frag_sem Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(&p->frag_sem); lock(&sb->s_type->i_mutex_key#26); lock(&p->frag_sem); lock(gadget_subsys.su_mutex); *** DEADLOCK *** 4 locks held by syz.2.623/8499: #0: ffff88802f824348 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2a3/0x330 fs/file.c:1040 #1: ffff88801feba418 (sb_writers#19){.+.+}-{0:0}, at: vfs_write+0x21e/0x9a0 fs/read_write.c:580 #2: ffff88802fec8688 (&buffer->mutex#2){+.+.}-{3:3}, at: configfs_write_iter+0x81/0x400 fs/configfs/file.c:226 #3: ffff888022e0c578 (&p->frag_sem){++++}-{3:3}, at: flush_write_buffer fs/configfs/file.c:205 [inline] #3: ffff888022e0c578 (&p->frag_sem){++++}-{3:3}, at: configfs_write_iter+0x215/0x400 fs/configfs/file.c:229 stack backtrace: CPU: 0 PID: 8499 Comm: syz.2.623 Not tainted syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026 Call Trace: dump_stack_lvl+0x18c/0x250 lib/dump_stack.c:106 check_noncircular+0x2fc/0x400 kernel/locking/lockdep.c:2187 check_prev_add kernel/locking/lockdep.c:3134 [inline] check_prevs_add kernel/locking/lockdep.c:3253 [inline] validate_chain kernel/locking/lockdep.c:3869 [inline] __lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137 lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754 __mutex_lock_common kernel/locking/mutex.c:603 [inline] __mutex_lock+0x135/0xc80 kernel/locking/mutex.c:747 uvcg_frame_dw_max_video_frame_buffer_size_store+0x115/0x370 drivers/usb/gadget/function/uvc_configfs.c:2023 flush_write_buffer fs/configfs/file.c:207 [inline] configfs_write_iter+0x312/0x400 fs/configfs/file.c:229 call_write_iter include/linux/fs.h:2018 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x474/0x9a0 fs/read_write.c:584 ksys_write+0x151/0x260 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x68/0xd2 RIP: 0033:0x7f09aab9e0d9 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:00007f09ab9a3028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f09aae25fa0 RCX: 00007f09aab9e0d9 RDX: 0000000000000004 RSI: 00002000000006c0 RDI: 0000000000000007 RBP: 00007f09aac35024 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f09aae26038 R14: 00007f09aae25fa0 R15: 00007fff4c311708