ALSA: usb-audio: Add sanity check for OOB writes at silencing
authorTakashi Iwai <tiwai@suse.de>
Mon, 16 Feb 2026 14:12:07 +0000 (15:12 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 16 Feb 2026 14:13:48 +0000 (15:13 +0100)
commitfba2105a157fffcf19825e4eea498346738c9948
tree72b2d7a995d91e513f27b62b1c8b1360109499ba
parent36adb51ac0b19edb32ffeea3fe66b174bad25ead
ALSA: usb-audio: Add sanity check for OOB writes at silencing

At silencing the playback URB packets in the implicit fb mode before
the actual playback, we blindly assume that the received packets fit
with the buffer size.  But when the setup in the capture stream
differs from the playback stream (e.g. due to the USB core limitation
of max packet size), such an inconsistency may lead to OOB writes to
the buffer, resulting in a crash.

For addressing it, add a sanity check of the transfer buffer size at
prepare_silent_urb(), and stop the data copy if the received data
overflows.  Also, report back the transfer error properly from there,
too.

Note that this doesn't fix the root cause of the playback error
itself, but this merely covers the kernel Oops.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=221076
Link: https://patch.msgid.link/20260216141209.1849200-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/endpoint.c