memory leak in uvcg_extension_ba_source_id_store
Subsystems (2)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 11028ab62899 Merge tag 'probes-fixes-v7.2-rc5' of git://gi.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=13b5b03e580000 kernel config: https://syzkaller.appspot.com/x/.config?x=ba7c2d1679fb08a2 dashboard link: https://syzkaller.appspot.com/bug?extid=54927260acba030187a6 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12985499580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16ab649e580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b677b453b580/disk-11028ab6.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/eec6e520d498/vmlinux-11028ab6.xz
kernel image: https://storage.googleapis.com/syzbot-assets/03c59bb4309c/bzImage-11028ab6.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
BUG: memory leak
unreferenced object 0xffff88810ddbd588 (size 8):
comm "syz.1.37", pid 6113, jiffies 4294948281
hex dump (first 8 bytes):
01 00 00 00 00 00 00 00 ........
backtrace (crc ccaa009e):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4597 [inline]
slab_alloc_node mm/slub.c:4917 [inline]
__do_kmalloc_node mm/slub.c:5333 [inline]
__kmalloc_noprof+0x3bf/0x550 mm/slub.c:5359
_kmalloc_noprof include/linux/slab.h:992 [inline]
_kmalloc_array_noprof include/linux/slab.h:1208 [inline]
uvcg_extension_ba_source_id_store+0xee/0x180 drivers/usb/gadget/function/uvc_configfs.c:1058
flush_write_buffer fs/configfs/file.c:207 [inline]
configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x3ac/0x720 fs/read_write.c:687
ksys_write+0xa5/0x170 fs/read_write.c:739
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xf8/0x610 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7fconnection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
syzbot
syzbotForwarded: #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 11028ab62899
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject: #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 11028ab62899
Author: [email protected]
From a6329c2864899c7c7ac2c20b9d3e04bf598c6870 Mon Sep 17 00:00:00 2001
From: Rituparna Warwatkar <[email protected]>
Date: Sat, 1 Aug 2026 03:31:03 +0000
Subject: [PATCH] usb: gadget: uvc: don't pack struct
uvcg_extension_unit_descriptor
kmemleak reports the baSourceID and bmControls arrays allocated by the UVC extension-unit configfs attributes as leaked, e.g.:
BUG: memory leak
unreferenced object 0xffff888114fee2c0 (size 8):
__kmalloc_noprof
uvcg_extension_ba_source_id_store
configfs_write_iter
vfs_write
ksys_writeThe arrays are not actually leaked: they are reachable through xu->desc.baSourceID / xu->desc.bmControls and are freed when the extension unit is removed. The problem is that struct uvcg_extension_unit_descriptor is marked __packed, so these two heap pointers are stored at unaligned offsets (22 and 31). kmemleak only scans memory on pointer-aligned boundaries, so it never sees the pointers and reports the arrays as unreferenced.
Unlike the UAPI struct uvc_extension_unit_descriptor, this is a purely in-memory staging structure: baSourceID and bmControls are pointers, not inline arrays, and the wire descriptor is assembled field by field in UVC_COPY_XU_DESCRIPTOR(). Nothing relies on the packed layout, so the __packed attribute is unnecessary and only serves to misalign the pointers.
Drop __packed so the pointers are naturally aligned and visible to kmemleak, silencing the false positive.
--- drivers/usb/gadget/function/uvc_configfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/uvc_configfs.h +1 -1
@@ -176,7 +176,7 @@ struct uvcg_extension_unit_descriptor {u8 bControlSize;u8 *bmControls;u8 iExtension; -} __packed; +};struct uvcg_extension {struct config_item item;
--
2.47.3
syzbot
syzbotForwarded: #syz test
In reply to syzbotFor archival purposes, forwarding an incoming command email to [email protected], [email protected].
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject: #syz test
Author: [email protected]
From a6329c2864899c7c7ac2c20b9d3e04bf598c6870 Mon Sep 17 00:00:00 2001
From: Rituparna Warwatkar <[email protected]>
Date: Sat, 1 Aug 2026 03:31:03 +0000
Subject: [PATCH] usb: gadget: uvc: don't pack struct
uvcg_extension_unit_descriptor
kmemleak reports the baSourceID and bmControls arrays allocated by the UVC extension-unit configfs attributes as leaked, e.g.:
BUG: memory leak
unreferenced object 0xffff888114fee2c0 (size 8):
__kmalloc_noprof
uvcg_extension_ba_source_id_store
configfs_write_iter
vfs_write
ksys_writeThe arrays are not actually leaked: they are reachable through xu->desc.baSourceID / xu->desc.bmControls and are freed when the extension unit is removed. The problem is that struct uvcg_extension_unit_descriptor is marked __packed, so these two heap pointers are stored at unaligned offsets (22 and 31). kmemleak only scans memory on pointer-aligned boundaries, so it never sees the pointers and reports the arrays as unreferenced.
Unlike the UAPI struct uvc_extension_unit_descriptor, this is a purely in-memory staging structure: baSourceID and bmControls are pointers, not inline arrays, and the wire descriptor is assembled field by field in UVC_COPY_XU_DESCRIPTOR(). Nothing relies on the packed layout, so the __packed attribute is unnecessary and only serves to misalign the pointers.
Drop __packed so the pointers are naturally aligned and visible to kmemleak, silencing the false positive.
--- drivers/usb/gadget/function/uvc_configfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/uvc_configfs.h +1 -1
@@ -176,7 +176,7 @@ struct uvcg_extension_unit_descriptor {u8 bControlSize;u8 *bmControls;u8 iExtension; -} __packed; +};struct uvcg_extension {struct config_item item;
--
2.47.3