summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-11-21 17:00:32 +0100
committerSasha Levin <alexander.levin@verizon.com>2017-12-08 18:01:03 -0500
commit0392f95be48f1601672f35a7831f4985fadea0d6 (patch)
tree9a25e14f675a2d589ea85496ad0798729ed45727 /sound
parentc3c314dc77d098dd9990c3fb39ce5f37ff29215d (diff)
ALSA: usb-audio: Fix potential out-of-bound access at parsing SU
[ Upstream commit f658f17b5e0e339935dca23e77e0f3cad591926b ] 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") Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/mixer.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 9fdec4d7542d..3ebfaa527825 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2020,7 +2020,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;