All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Fix DMA buffer out-of-bounds write when fill_max is set
@ 2026-07-28 20:17 Sonali Pradhan
  2026-07-29  6:25 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Sonali Pradhan @ 2026-07-28 20:17 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: Daniel Mack, Gordon Chen, Kees Cook, Jussi Laako, linux-sound,
	linux-kernel, stable, Sonali Pradhan

When a USB audio endpoint requests full packet transfers via the fill_max
descriptor flag, data_ep_set_params() promotes ep->curpacksize to
ep->maxpacksize. However, maxsize is left at the original sample-rate
derived value.

Since u->buffer_size is allocated as maxsize * packets, the resulting
DMA buffer is far too small for the requested transfer length. When the
USB host controller streams up to curpacksize bytes per packet, it writes
past the end of the buffer via DMA, corrupting kernel heap memory.

Update maxsize to curpacksize when fill_max is set so that the allocated
DMA buffer size matches the actual transfer request size.

Fixes: 8fdff6a319e7 ("ALSA: snd-usb: implement new endpoint streaming model")
Cc: stable@vger.kernel.org
Assisted-by: Jetski:Gemini-3.6-Flash
Signed-off-by: Sonali Pradhan <sonalipradhan@google.com>
---
 sound/usb/endpoint.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 24cd7692bd01..d825c09a766a 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -1172,6 +1172,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep)
 		ep->curpacksize = ep->maxpacksize;
 	else
 		ep->curpacksize = maxsize;
+	maxsize = ep->curpacksize;
 
 	if (snd_usb_get_speed(chip->dev) != USB_SPEED_FULL) {
 		packs_per_ms = 8 >> ep->datainterval;
-- 
2.55.0.487.gaf234c4eb3-goog


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

end of thread, other threads:[~2026-07-29  6:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 20:17 [PATCH] ALSA: usb-audio: Fix DMA buffer out-of-bounds write when fill_max is set Sonali Pradhan
2026-07-29  6:25 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.