[syzbot] [usb?] memory leak in build_fu_desc
From: syzbot
Date: Thu Dec 03 2026 - 04:17:22 EST
Hello,
syzbot found the following issue on:
HEAD commit: 3f963696da44 Merge tag 'media/v7.4-3' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12652e6d580000
kernel config: https://syzkaller.appspot.com/x/.config?x=a4bc392f8c76896d
dashboard link: https://syzkaller.appspot.com/bug?extid=da5ce3f4a00c8cbe0d4e
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=152ea9d5580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14581e73580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ffe6560d5a4f/disk-3f963696.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/e09d84a380b1/vmlinux-3f963696.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f8a6bfadef06/bzImage-3f963696.xz
AI-generated root cause summary:
In drivers/usb/gadget/function/f_uac2.c, in_feature_unit_desc and
out_feature_unit_desc are stored as global static pointers rather than
per-instance fields of struct f_uac2. When multiple uac2 function instances are
bound (such as two uac2 functions in one USB gadget configuration or across
multiple gadgets), subsequent calls to afunc_bind() allocate new descriptors via
build_fu_desc() and overwrite these global pointers without freeing the previous
allocations. As a result, the earlier instances' uac2_feature_unit_descriptor
objects become unreferenced and are leaked when afunc_unbind() later frees only
the most recently stored pointers. Additionally, sharing these unsynchronized
global pointers across instances allows interleaved or concurrent bind/unbind
operations across gadgets to trigger NULL-pointer dereferences, use-after-free,
or double-free errors.
full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=da5ce3f4a00c8cbe0d4e
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+da5ce3f4a00c8cbe0d4e@xxxxxxxxxxxxxxxxxxxxxxxxx
BUG: memory leak
unreferenced object 0xffff888111d43640 (size 32):
comm "syz.0.18", pid 5970, jiffies 4294944041
hex dump (first 32 bytes):
12 24 06 05 01 0f 00 00 00 00 00 00 00 00 00 00 .$..............
00 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc f0b3e9e9):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4733 [inline]
slab_alloc_node mm/slub.c:5033 [inline]
__do_kmalloc_node mm/slub.c:5530 [inline]
__kmalloc_noprof+0x3ce/0x510 mm/slub.c:5556
_kmalloc_noprof include/linux/slab.h:995 [inline]
_kzalloc_noprof include/linux/slab.h:1312 [inline]
build_fu_desc+0x3f/0x70 drivers/usb/gadget/function/f_uac2.c:773
afunc_bind+0x1414/0x16a0 drivers/usb/gadget/function/f_uac2.c:1062
usb_add_function+0xca/0x270 drivers/usb/gadget/composite.c:333
configfs_composite_bind+0x667/0x9b0 drivers/usb/gadget/configfs.c:1803
gadget_bind_driver+0xed/0x3a0 drivers/usb/gadget/udc/core.c:1671
call_driver_probe drivers/base/dd.c:629 [inline]
really_probe+0x12f/0x3a0 drivers/base/dd.c:707
__driver_probe_device+0xe9/0x1a0 drivers/base/dd.c:869
driver_probe_device+0x28/0xf0 drivers/base/dd.c:899
__driver_attach drivers/base/dd.c:1300 [inline]
__driver_attach+0x10e/0x210 drivers/base/dd.c:1240
bus_for_each_dev+0xb8/0x120 drivers/base/bus.c:383
bus_add_driver+0x24c/0x2b0 drivers/base/bus.c:782
driver_register+0xb1/0x140 drivers/base/driver.c:174
usb_gadget_register_driver_owner+0x69/0xe0 drivers/usb/gadget/udc/core.c:1761
gadget_dev_desc_UDC_store+0x153/0x1e0 drivers/usb/gadget/configfs.c:300
flush_write_buffer fs/configfs/file.c:207 [inline]
configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
BUG: memory leak
unreferenced object 0xffff888111d43da0 (size 32):
comm "syz.0.18", pid 5970, jiffies 4294944041
hex dump (first 32 bytes):
12 24 06 06 02 0f 00 00 00 00 00 00 00 00 00 00 .$..............
00 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc cc648ab8):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4733 [inline]
slab_alloc_node mm/slub.c:5033 [inline]
__do_kmalloc_node mm/slub.c:5530 [inline]
__kmalloc_noprof+0x3ce/0x510 mm/slub.c:5556
_kmalloc_noprof include/linux/slab.h:995 [inline]
_kzalloc_noprof include/linux/slab.h:1312 [inline]
build_fu_desc+0x3f/0x70 drivers/usb/gadget/function/f_uac2.c:773
afunc_bind+0x143b/0x16a0 drivers/usb/gadget/function/f_uac2.c:1067
usb_add_function+0xca/0x270 drivers/usb/gadget/composite.c:333
configfs_composite_bind+0x667/0x9b0 drivers/usb/gadget/configfs.c:1803
gadget_bind_driver+0xed/0x3a0 drivers/usb/gadget/udc/core.c:1671
call_driver_probe drivers/base/dd.c:629 [inline]
really_probe+0x12f/0x3a0 drivers/base/dd.c:707
__driver_probe_device+0xe9/0x1a0 drivers/base/dd.c:869
driver_probe_device+0x28/0xf0 drivers/base/dd.c:899
__driver_attach drivers/base/dd.c:1300 [inline]
__driver_attach+0x10e/0x210 drivers/base/dd.c:1240
bus_for_each_dev+0xb8/0x120 drivers/base/bus.c:383
bus_add_driver+0x24c/0x2b0 drivers/base/bus.c:782
driver_register+0xb1/0x140 drivers/base/driver.c:174
usb_gadget_register_driver_owner+0x69/0xe0 drivers/usb/gadget/udc/core.c:1761
gadget_dev_desc_UDC_store+0x153/0x1e0 drivers/usb/gadget/configfs.c:300
flush_write_buffer fs/configfs/file.c:207 [inline]
configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
BUG: memory leak
unreferenced object 0xffff888111d43800 (size 32):
comm "syz.0.19", pid 5981, jiffies 4294944049
hex dump (first 32 bytes):
12 24 06 05 01 0f 00 00 00 00 00 00 00 00 00 00 .$..............
00 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc f0b3e9e9):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4733 [inline]
slab_alloc_node mm/slub.c:5033 [inline]
__do_kmalloc_node mm/slub.c:5530 [inline]
__kmalloc_noprof+0x3ce/0x510 mm/slub.c:5556
_kmalloc_noprof include/linux/slab.h:995 [inline]
_kzalloc_noprof include/linux/slab.h:1312 [inline]
build_fu_desc+0x3f/0x70 drivers/usb/gadget/function/f_uac2.c:773
afunc_bind+0x1414/0x16a0 drivers/usb/gadget/function/f_uac2.c:1062
usb_add_function+0xca/0x270 drivers/usb/gadget/composite.c:333
configfs_composite_bind+0x667/0x9b0 drivers/usb/gadget/configfs.c:1803
gadget_bind_driver+0xed/0x3a0 drivers/usb/gadget/udc/core.c:1671
call_driver_probe drivers/base/dd.c:629 [inline]
really_probe+0x12f/0x3a0 drivers/base/dd.c:707
__driver_probe_device+0xe9/0x1a0 drivers/base/dd.c:869
driver_probe_device+0x28/0xf0 drivers/base/dd.c:899
__driver_attach drivers/base/dd.c:1300 [inline]
__driver_attach+0x10e/0x210 drivers/base/dd.c:1240
bus_for_each_dev+0xb8/0x120 drivers/base/bus.c:383
bus_add_driver+0x24c/0x2b0 drivers/base/bus.c:782
driver_register+0xb1/0x140 drivers/base/driver.c:174
usb_gadget_register_driver_owner+0x69/0xe0 drivers/usb/gadget/udc/core.c:1761
gadget_dev_desc_UDC_store+0x153/0x1e0 drivers/usb/gadget/configfs.c:300
flush_write_buffer fs/configfs/file.c:207 [inline]
configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
BUG: memory leak
unreferenced object 0xffff888111d43820 (size 32):
comm "syz.0.19", pid 5981, jiffies 4294944049
hex dump (first 32 bytes):
12 24 06 06 02 0f 00 00 00 00 00 00 00 00 00 00 .$..............
00 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc cc648ab8):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4733 [inline]
slab_alloc_node mm/slub.c:5033 [inline]
__do_kmalloc_node mm/slub.c:5530 [inline]
__kmalloc_noprof+0x3ce/0x510 mm/slub.c:5556
_kmalloc_noprof include/linux/slab.h:995 [inline]
_kzalloc_noprof include/linux/slab.h:1312 [inline]
build_fu_desc+0x3f/0x70 drivers/usb/gadget/function/f_uac2.c:773
afunc_bind+0x143b/0x16a0 drivers/usb/gadget/function/f_uac2.c:1067
usb_add_function+0xca/0x270 drivers/usb/gadget/composite.c:333
configfs_composite_bind+0x667/0x9b0 drivers/usb/gadget/configfs.c:1803
gadget_bind_driver+0xed/0x3a0 drivers/usb/gadget/udc/core.c:1671
call_driver_probe drivers/base/dd.c:629 [inline]
really_probe+0x12f/0x3a0 drivers/base/dd.c:707
__driver_probe_device+0xe9/0x1a0 drivers/base/dd.c:869
driver_probe_device+0x28/0xf0 drivers/base/dd.c:899
__driver_attach drivers/base/dd.c:1300 [inline]
__driver_attach+0x10e/0x210 drivers/base/dd.c:1240
bus_for_each_dev+0xb8/0x120 drivers/base/bus.c:383
bus_add_driver+0x24c/0x2b0 drivers/base/bus.c:782
driver_register+0xb1/0x140 drivers/base/driver.c:174
usb_gadget_register_driver_owner+0x69/0xe0 drivers/usb/gadget/udc/core.c:1761
gadget_dev_desc_UDC_store+0x153/0x1e0 drivers/usb/gadget/configfs.c:300
flush_write_buffer fs/configfs/file.c:207 [inline]
configfs_write_iter+0x10d/0x1a0 fs/configfs/file.c:229
connection 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 syzkaller@xxxxxxxxxxxxxxxx.
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 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