diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-05-10 18:06:59 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-05-10 18:08:38 +0300 |
commit | e84749a78dc82bc545f12ce009e3dbcc2c5a8a91 (patch) | |
tree | de7946aafb61ac751a531065920c599003027f27 /sound/usb/midi.c | |
parent | c1b55029493879f5bd585ff79f326e71f0bc05e3 (diff) | |
download | linux-e84749a78dc82bc545f12ce009e3dbcc2c5a8a91.tar.xz |
ALSA: usb-audio: Validate MS endpoint descriptors
snd_usbmidi_get_ms_info() may access beyond the border when a
malformed descriptor is passed. This patch adds the sanity checks of
the given MS endpoint descriptors, and skips invalid ones.
Reported-by: syzbot+6bb23a5d5548b93c94aa@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210510150659.17710-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/midi.c')
-rw-r--r-- | sound/usb/midi.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sound/usb/midi.c b/sound/usb/midi.c index a10ac75969a8..649eb8d1ab7d 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -1956,8 +1956,12 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi *umidi, ms_ep = find_usb_ms_endpoint_descriptor(hostep); if (!ms_ep) continue; + if (ms_ep->bLength <= sizeof(*ms_ep)) + continue; if (ms_ep->bNumEmbMIDIJack > 0x10) continue; + if (ms_ep->bLength < sizeof(*ms_ep) + ms_ep->bNumEmbMIDIJack) + continue; if (usb_endpoint_dir_out(ep)) { if (endpoints[epidx].out_ep) { if (++epidx >= MIDI_MAX_ENDPOINTS) { |