aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-11-21 11:00:32 -0500
committerTakashi Iwai <tiwai@suse.de>2017-11-21 11:50:31 -0500
commitf658f17b5e0e339935dca23e77e0f3cad591926b (patch)
treebb2746f2604b3c41bd44c9b0f181ed47d6fc86fa
parentd937cd6790a2bef2d07b500487646bd794c039bb (diff)
ALSA: usb-audio: Fix potential out-of-bound access at parsing SU
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>
-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 b8ce651e392c..61b348383de8 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,
2098 const struct usbmix_name_map *map; 2098 const struct usbmix_name_map *map;
2099 char **namelist; 2099 char **namelist;
2100 2100
2101 if (!desc->bNrInPins || desc->bLength < 5 + desc->bNrInPins) { 2101 if (desc->bLength < 5 || !desc->bNrInPins ||
2102 desc->bLength < 5 + desc->bNrInPins) {
2102 usb_audio_err(state->chip, 2103 usb_audio_err(state->chip,
2103 "invalid SELECTOR UNIT descriptor %d\n", unitid); 2104 "invalid SELECTOR UNIT descriptor %d\n", unitid);
2104 return -EINVAL; 2105 return -EINVAL;