From: Takashi Iwai <tiwai@suse.de>
To: Sonali Pradhan <sonalipradhan@google.com>
Cc: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
Daniel Mack <zonque@gmail.com>,
Gordon Chen <chengordon326@gmail.com>,
Kees Cook <kees@kernel.org>, Jussi Laako <jussi@sonarnerd.net>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: usb-audio: Fix DMA buffer out-of-bounds write when fill_max is set
Date: Wed, 29 Jul 2026 08:25:15 +0200 [thread overview]
Message-ID: <87se525n3o.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260728201716.2347726-1-sonalipradhan@google.com>
On Tue, 28 Jul 2026 22:17:16 +0200,
Sonali Pradhan wrote:
>
> 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;
>
Unconditionally reassigning here makes harder to understand the
intention. So I modified slightly to make the reassignment
conditional, only when ep->fill_max is set.
if (ep->fill_max) {
ep->curpacksize = ep->maxpacksize;
maxsize = ep->curpacksize;
} else {
ep->curpacksize = maxsize;
}
Applied the fix in the form above now. Thanks.
Takashi
prev parent reply other threads:[~2026-07-29 6:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=87se525n3o.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=chengordon326@gmail.com \
--cc=jussi@sonarnerd.net \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=sonalipradhan@google.com \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
--cc=zonque@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