aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/quirks.c
diff options
context:
space:
mode:
authorTakashi Iwai <[email protected]>2019-08-20 15:17:09 +0000
committerTakashi Iwai <[email protected]>2019-08-22 08:35:59 +0000
commit57f8770620e9b51c61089751f0b5ad3dbe376ff2 (patch)
tree3302223d107681aa8b7558e68fdf1bf322cdc4b4 /sound/usb/quirks.c
parentALSA: usb-audio: Check mixer unit bitmap yet more strictly (diff)
downloadkernel-57f8770620e9b51c61089751f0b5ad3dbe376ff2.tar.gz
kernel-57f8770620e9b51c61089751f0b5ad3dbe376ff2.zip
ALSA: usb-audio: More validations of descriptor units
Introduce a new helper to validate each audio descriptor unit before and check the unit before actually accessing it. This should harden against the OOB access cases with malformed descriptors that have been recently frequently reported by fuzzers. The existing descriptor checks are still kept although they become superfluous after this patch. They'll be cleaned up eventually later. Signed-off-by: Takashi Iwai <[email protected]>
Diffstat (limited to 'sound/usb/quirks.c')
-rw-r--r--sound/usb/quirks.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 78858918cbc1..7e9735aa7ac9 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -248,6 +248,9 @@ static int create_yamaha_midi_quirk(struct snd_usb_audio *chip,
NULL, USB_MS_MIDI_OUT_JACK);
if (!injd && !outjd)
return -ENODEV;
+ if (!snd_usb_validate_midi_desc(injd) ||
+ !snd_usb_validate_midi_desc(outjd))
+ return -ENODEV;
if (injd && (injd->bLength < 5 ||
(injd->bJackType != USB_MS_EMBEDDED &&
injd->bJackType != USB_MS_EXTERNAL)))