Commit 86f86e6fdedc ("ALSA: ua101: reject mismatched capture/playback packet sizes") rejects a device at probe time when a capture packet of wMaxPacketSize bytes would carry more frames than fit into a playback packet. It assumed that genuine hardware declares proportional packet sizes, but the UA-1000 does not: capture EP 0x81: 12 ch x 4 bytes, wMaxPacketSize 720 -> 15 frames playback EP 0x02: 10 ch x 4 bytes, wMaxPacketSize 560 -> 14 frames so the UA-1000 now fails to probe with playback packet size 560 too small for 15 capture frames In practice the device sends about rate/8000 frames per packet at high speed (6 at 48 kHz, 12 at 96 kHz), which always fits the playback packet. The out-of-bounds write has a single source: capture_urb_complete() stores the received frame count in rate_feedback[], and both start_usb_playback() and playback_work() take their packet sizes only from that FIFO. Clamp the value there to what fits into one playback packet, so the playback URB buffer cannot be overrun whatever the descriptors say, and relax the probe check to require only that one packet at the nominal rate fits. Tested on a UA-1000 (0582:0044): the device probes again, and playback and capture both work. Fixes: 86f86e6fdedc ("ALSA: ua101: reject mismatched capture/playback packet sizes") Cc: stable@vger.kernel.org Reported-by: London grad Closes: https://lore.kernel.org/all/CANd6Td+b6ituLFzkhvX09vricCY541fQapNOk3rTa=74zWA5LA@mail.gmail.com/ Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222261 Signed-off-by: Suto, Masanori --- Hi Takashi, To answer your question earlier in this thread: on my UA-1000 (0582:0044, bcdDevice 1.07), reverting 86f86e6fdedc alone makes the device work again. It is registered in /proc/asound/cards, and playback and capture both work. Without the revert it fails to probe with "playback packet size 560 too small for 15 capture frames", as in the earlier report. So the commit is confirmed as the cause. A plain revert would reopen CVE-2026-98741, so this patch keeps the protection by clamping the packet size where it is produced instead of rejecting the device. With this patch applied, playback and capture also both work. Tested on linux-zen 7.3.6-zen1; sound/usb/misc/ua101.c there is identical to mainline. To check that the 15-frame worst case does not happen on real hardware, I captured the isochronous traffic with usbmon: 60 s of simultaneous playback and capture at each rate the UA-1000 supports, about 480000 packets each. Frames per packet, from the actual capture length (EP 0x81) and the submitted playback length (EP 0x02): rate capture frames per packet max 44.1 kHz 5: 48.76% 6: 51.24% 6 48 kHz 5: 1.14% 6: 97.74% 7: 1.12% 7 88.2 kHz 10: 1.04% 11: 95.45% 12: 3.52% 12 96 kHz 11: 0.08% 12: 99.86% 13: 0.06% 13 Playback used exactly the same distribution at every rate. The maximum is 13 frames at 96 kHz, which fits the 14-frame playback packet. The 15 frames assumed from wMaxPacketSize never occur: the device stays within one frame of rate/8000. The clamp warning added by this patch never appeared in the kernel log during these runs. The same breakage was also reported on LinuxMusicians: https://linuxmusicians.com/viewtopic.php?p=189180 #regzbot ^introduced: 86f86e6fdedc sound/usb/misc/ua101.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index bd8e0ed..196a588 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -371,7 +371,7 @@ static void capture_urb_complete(struct urb *urb) struct ua101_urb *ua_urb = urb->context; struct ua101 *ua = ua_urb->ua; struct ua101_stream *stream = &ua->capture; - unsigned int frames, write_ptr; + unsigned int frames, max_frames, write_ptr; bool do_period_elapsed; int err; @@ -402,6 +402,21 @@ static void capture_urb_complete(struct urb *urb) goto stream_stopped; } + /* + * The playback stream reuses this packet size, but its + * URB buffers hold only playback.max_packet_bytes. The + * capture packet size comes from the device, so clamp it + * to what fits into one playback packet. + */ + max_frames = ua->playback.max_packet_bytes / + ua->playback.frame_bytes; + if (unlikely(frames > max_frames)) { + dev_warn_ratelimited(&ua->dev->dev, + "capture packet of %u frames clamped\n", + frames); + frames = max_frames; + } + /* append packet size to FIFO */ write_ptr = ua->rate_feedback_start; add_with_wraparound(ua, &write_ptr, ua->rate_feedback_count); @@ -1031,12 +1046,17 @@ static int detect_usb_format(struct ua101 *ua) ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, usb_endpoint_num(epd)); ua->playback.max_packet_bytes = usb_endpoint_maxp(epd); - if (ua->capture.max_packet_bytes / ua->capture.frame_bytes * + /* + * capture_urb_complete() clamps the packet sizes passed to the playback + * stream to playback.max_packet_bytes, so only the nominal rate must + * fit here. wMaxPacketSize of the capture endpoint may legitimately + * be larger (e.g. UA-1000). + */ + if (DIV_ROUND_UP(ua->rate, ua->packets_per_second) * ua->playback.frame_bytes > ua->playback.max_packet_bytes) { dev_err(&ua->dev->dev, - "playback packet size %u too small for %u capture frames\n", - ua->playback.max_packet_bytes, - ua->capture.max_packet_bytes / ua->capture.frame_bytes); + "playback packet size %u too small for %u Hz\n", + ua->playback.max_packet_bytes, ua->rate); return -ENXIO; } return 0; -- 2.43.0