Skip to content

Commit

Permalink
ALSA: usb-audio: Fix potential out-of-bound access at parsing SU
Browse files Browse the repository at this point in the history
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: 99fc864 ("ALSA: usb-mixer: parse descriptors with structs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Nov 21, 2017
1 parent d937cd6 commit f658f17
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/usb/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f658f17

Please sign in to comment.