]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: usb-audio: Fix UAC3 cluster descriptor size check
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Fri, 24 Apr 2026 21:50:10 +0000 (18:50 -0300)
committerTakashi Iwai <tiwai@suse.de>
Mon, 27 Apr 2026 11:51:07 +0000 (13:51 +0200)
The UAC3 cluster descriptor length check in
snd_usb_get_audioformat_uac3()was added to
make sure that the buffer is large enough for
a struct uac3_cluster_header_descriptor before the
returned data is cast and used.

However, the check uses sizeof(cluster), where cluster
is a pointer, not the size of the descriptor header.
This makes the validation depend on the architecture
pointer size and does not match the intended object size.

Check against sizeof(*cluster) instead.

Fixes: fb4e2a6e8f28 ("ALSA: usb-audio: Fix out-of-bounds read in snd_usb_get_audioformat_uac3()")
Cc: stable@vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260424-alsa-usb-uac3-cluster-size-v1-1-99a5808898a3@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/stream.c

index 2532bf97e05e001ddb6b879eb98082617982bb18..6c51226f771b67b2c21f04100e083f13ec7db266 100644 (file)
@@ -1003,7 +1003,7 @@ 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))
+       if (wLength < sizeof(*cluster))
                return NULL;
        cluster = kzalloc(wLength, GFP_KERNEL);
        if (!cluster)