Linux USB
 help / color / mirror / Atom feed
* [PATCH 0/4] usb: gadget: f_uac1/f_uac2: fix descriptor leaks and NULL deref with multiple instances
@ 2026-12-03 19:32 Vineet Thakran
  2026-12-03 19:32 ` [PATCH 1/4] usb: gadget: f_uac2: use per-instance feature unit IDs in control requests Vineet Thakran
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Vineet Thakran @ 2026-12-03 19:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Neill Kapron
  Cc: Ruslan Bilovol, Pavel Hofman, linux-usb, Vineet Thakran

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-12-03 19:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 19:32 [PATCH 0/4] usb: gadget: f_uac1/f_uac2: fix descriptor leaks and NULL deref with multiple instances Vineet Thakran
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
2026-12-03 19:56 ` [PATCH 0/4] usb: gadget: f_uac1/f_uac2: fix descriptor leaks and NULL deref with multiple instances sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox