mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-18 14:21:07 +00:00
ALSA: usb-audio: Bound MIDI endpoint descriptor scans
commit d6854daa67be623860f4e1873fd3d3c275aba4ed upstream.
snd_usbmidi_get_ms_info() validates the internal MIDIStreaming endpoint
descriptor size before using baAssocJackID[], but the descriptor walker can
still return a class-specific endpoint descriptor whose bLength exceeds the
remaining bytes in the endpoint-extra scan.
That leaves later flexible-array reads bounded by bLength, but not by the
remaining bytes in the endpoint-extra scan.
Stop walking when bLength is zero or
extends past the remaining endpoint-extra scan.
Fixes: 5c6cd7021a05 ("ALSA: usb-audio: Fix case when USB MIDI interface has more than one extra endpoint descriptor")
Cc: stable@vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260507-usb-midi-endpoint-scan-bounds-v1-1-329d7348160e@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
e8085ad769
commit
eb5cdcb9df
@ -1904,15 +1904,17 @@ static struct usb_ms_endpoint_descriptor *find_usb_ms_endpoint_descriptor(
|
||||
while (extralen > 3) {
|
||||
struct usb_ms_endpoint_descriptor *ms_ep =
|
||||
(struct usb_ms_endpoint_descriptor *)extra;
|
||||
int length = ms_ep->bLength;
|
||||
|
||||
if (ms_ep->bLength > 3 &&
|
||||
if (!length || length > extralen)
|
||||
break;
|
||||
|
||||
if (length > 3 &&
|
||||
ms_ep->bDescriptorType == USB_DT_CS_ENDPOINT &&
|
||||
ms_ep->bDescriptorSubtype == UAC_MS_GENERAL)
|
||||
return ms_ep;
|
||||
if (!extra[0])
|
||||
break;
|
||||
extralen -= extra[0];
|
||||
extra += extra[0];
|
||||
extralen -= length;
|
||||
extra += length;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user