From: Vineet Thakran <vineet789thakran@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Neill Kapron <nkapron@google.com>
Cc: Ruslan Bilovol <ruslan.bilovol@gmail.com>,
Pavel Hofman <pavel.hofman@ivitera.com>,
linux-usb@vger.kernel.org,
Vineet Thakran <vineet789thakran@gmail.com>
Subject: [PATCH 0/4] usb: gadget: f_uac1/f_uac2: fix descriptor leaks and NULL deref with multiple instances
Date: Thu, 3 Dec 2026 19:32:13 +0000 [thread overview]
Message-ID: <20261203193217.465889-1-vineet789thakran@gmail.com> (raw)
f_uac1 and f_uac2 keep the dynamically allocated feature unit (and, in
f_uac1, AC header) descriptors in file-scope pointers shared by all
instances. With more than one instance this leaks descriptors on every
bind (reported by syzbot for f_uac2), and once one instance unbinds, a
feature unit control request to any other bound instance dereferences
a NULL pointer.
Patches 1 and 3 make the control request handlers use the unit IDs
already stored per instance. Patches 2 and 4 then free the descriptors
at the end of bind, as usb_assign_descriptors() has copied them by then.
Testing (next-20261127, arm64 QEMU, usbip-vudc as UDC, kmemleak on):
- syzbot's C reproducer: reports the build_fu_desc leak before the
series; runs for 180 s without any leak after it.
- Two uac2 and two uac1 instances in one config, bound/unbound for
3 and 8 cycles: kmemleak reports leaked FU descriptors before the
series (10 objects after 3 cycles, 27 after 8) and none after.
Counting allocations and frees with temporary instrumentation also
confirms the uac1 AC header leak, which kmemleak does not report:
3 of 6 freed before, 6 of 6 after.
- Two gadgets on two vudc instances, unbinding the first and attaching
the second to vhci-hcd: both drivers oops on the first feature unit
control request before the series. After it, snd-usb-audio enumerates
the device and creates all volume/mute controls.
Both drivers still keep their other descriptors in static variables;
this series only addresses the dynamically allocated ones.
Vineet Thakran (4):
usb: gadget: f_uac2: use per-instance feature unit IDs in control
requests
usb: gadget: f_uac2: fix feature unit descriptor leak
usb: gadget: f_uac1: use per-instance feature unit IDs in control
requests
usb: gadget: f_uac1: fix feature unit and AC header descriptor leak
drivers/usb/gadget/function/f_uac1.c | 83 +++++++++++++---------------
drivers/usb/gadget/function/f_uac2.c | 83 ++++++++++++++--------------
2 files changed, 78 insertions(+), 88 deletions(-)
base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d
--
2.43.0
next reply other threads:[~2026-12-03 19:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 19:32 Vineet Thakran [this message]
2026-12-03 19:32 ` [PATCH 1/4] usb: gadget: f_uac2: use per-instance feature unit IDs in control requests Vineet Thakran
2026-12-03 19:32 ` [PATCH 2/4] usb: gadget: f_uac2: fix feature unit descriptor leak Vineet Thakran
2026-12-03 19:54 ` sashiko-bot
2026-12-03 19:32 ` [PATCH 3/4] usb: gadget: f_uac1: use per-instance feature unit IDs in control requests Vineet Thakran
2026-12-03 19:32 ` [PATCH 4/4] usb: gadget: f_uac1: fix feature unit and AC header descriptor leak Vineet Thakran
2026-12-03 19:52 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203193217.465889-1-vineet789thakran@gmail.com \
--to=vineet789thakran@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.com \
--cc=pavel.hofman@ivitera.com \
--cc=ruslan.bilovol@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox