]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: usb-audio: Fix out-of-bounds read in snd_usb_get_audioformat_uac3()
authorYoungjun Lee <yjjuny.lee@samsung.com>
Mon, 23 Jun 2025 11:05:25 +0000 (20:05 +0900)
committerTakashi Iwai <tiwai@suse.de>
Mon, 23 Jun 2025 15:08:56 +0000 (17:08 +0200)
In snd_usb_get_audioformat_uac3(), the length value returned from
snd_usb_ctl_msg() is used directly for memory allocation without
validation. This length is controlled by the USB device.

The allocated buffer is cast to a uac3_cluster_header_descriptor
and its fields are accessed without verifying that the buffer
is large enough. If the device returns a smaller than expected
length, this leads to an out-of-bounds read.

Add a length check to ensure the buffer is large enough for
uac3_cluster_header_descriptor.

Signed-off-by: Youngjun Lee <yjjuny.lee@samsung.com>
Fixes: 9a2fe9b801f5 ("ALSA: usb: initial USB Audio Device Class 3.0 support")
Link: https://patch.msgid.link/20250623-uac3-oob-fix-v1-1-527303eaf40a@samsung.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/stream.c

index c1ea8844a46fc420ee703b8640580cef851ef4b7..aa91d63749f2ca34e906d1e1366ca9f095ac01ae 100644 (file)
@@ -987,6 +987,8 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
         * and request Cluster Descriptor
         */
        wLength = le16_to_cpu(hc_header.wLength);
+       if (wLength < sizeof(cluster))
+               return NULL;
        cluster = kzalloc(wLength, GFP_KERNEL);
        if (!cluster)
                return ERR_PTR(-ENOMEM);