Skip to content

Commit 0b6cede

Browse files
tiwaigregkh
authored andcommitted
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: 99fc864 ("ALSA: usb-mixer: parse descriptors with structs") Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d1316b9 commit 0b6cede

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sound/usb/mixer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
20262026
const struct usbmix_name_map *map;
20272027
char **namelist;
20282028

2029-
if (!desc->bNrInPins || desc->bLength < 5 + desc->bNrInPins) {
2029+
if (desc->bLength < 5 || !desc->bNrInPins ||
2030+
desc->bLength < 5 + desc->bNrInPins) {
20302031
usb_audio_err(state->chip,
20312032
"invalid SELECTOR UNIT descriptor %d\n", unitid);
20322033
return -EINVAL;

0 commit comments

Comments
 (0)