Skip to content

Commit d1316b9

Browse files
tiwaigregkh
authored andcommitted
ALSA: usb-audio: Add sanity checks to FE parser
commit d937cd6790a2bef2d07b500487646bd794c039bb upstream. When the usb-audio descriptor contains the malformed feature unit description with a too short length, the driver may access out-of-bounds. Add a sanity check of the header size at the beginning of parse_audio_feature_unit(). Fixes: 23caaf1 ("ALSA: usb-mixer: Add support for Audio Class v2.0") Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b71cf75 commit d1316b9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

sound/usb/mixer.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,12 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
13971397
__u8 *bmaControls;
13981398

13991399
if (state->mixer->protocol == UAC_VERSION_1) {
1400+
if (hdr->bLength < 7) {
1401+
usb_audio_err(state->chip,
1402+
"unit %u: invalid UAC_FEATURE_UNIT descriptor\n",
1403+
unitid);
1404+
return -EINVAL;
1405+
}
14001406
csize = hdr->bControlSize;
14011407
if (!csize) {
14021408
usb_audio_dbg(state->chip,
@@ -1414,6 +1420,12 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
14141420
}
14151421
} else {
14161422
struct uac2_feature_unit_descriptor *ftr = _ftr;
1423+
if (hdr->bLength < 6) {
1424+
usb_audio_err(state->chip,
1425+
"unit %u: invalid UAC_FEATURE_UNIT descriptor\n",
1426+
unitid);
1427+
return -EINVAL;
1428+
}
14171429
csize = 4;
14181430
channels = (hdr->bLength - 6) / 4 - 1;
14191431
bmaControls = ftr->bmaControls;

0 commit comments

Comments
 (0)