From: Takashi Iwai Date: Tue, 21 Nov 2017 16:00:32 +0000 (+0100) Subject: ALSA: usb-audio: Fix potential out-of-bound access at parsing SU X-Git-Tag: v4.14.3~105 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f7873c9945dd026e20d006dd18b75b8f05cdb5a;p=platform%2Fkernel%2Flinux-exynos.git ALSA: usb-audio: Fix potential out-of-bound access at parsing SU commit f658f17b5e0e339935dca23e77e0f3cad591926b upstream. The usb-audio driver may trigger an out-of-bound access at parsing a malformed selector unit, as it checks the header length only after evaluating bNrInPins field, which can be already above the given length. Fix it by adding the length check beforehand. Fixes: 99fc86450c43 ("ALSA: usb-mixer: parse descriptors with structs") Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 9bc34cb..2b835cc 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -2098,7 +2098,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, const struct usbmix_name_map *map; char **namelist; - if (!desc->bNrInPins || desc->bLength < 5 + desc->bNrInPins) { + if (desc->bLength < 5 || !desc->bNrInPins || + desc->bLength < 5 + desc->bNrInPins) { usb_audio_err(state->chip, "invalid SELECTOR UNIT descriptor %d\n", unitid); return -EINVAL;