Skip to content

Commit fb4e2a6

Browse files
Youngjun Leetiwai
authored andcommitted
ALSA: usb-audio: Fix out-of-bounds read in snd_usb_get_audioformat_uac3()
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 <[email protected]> Fixes: 9a2fe9b ("ALSA: usb: initial USB Audio Device Class 3.0 support") Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 9a07ca9 commit fb4e2a6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/usb/stream.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
987987
* and request Cluster Descriptor
988988
*/
989989
wLength = le16_to_cpu(hc_header.wLength);
990+
if (wLength < sizeof(cluster))
991+
return NULL;
990992
cluster = kzalloc(wLength, GFP_KERNEL);
991993
if (!cluster)
992994
return ERR_PTR(-ENOMEM);

0 commit comments

Comments
 (0)