Skip to content

Commit 2f38cf7

Browse files
committed
ALSA: usb: Fix UBSAN warning in parse_audio_unit()
A malformed USB descriptor may pass the lengthy mixer description with a lot of channels, and this may overflow the 32bit integer shift size, as caught by syzbot UBSAN test. Although this won't cause any real trouble, it's better to address. This patch introduces a sanity check of the number of channels to bail out the parsing when too many channels are found. Reported-by: [email protected] Closes: https://lore.kernel.org/[email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5fa87a0 commit 2f38cf7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sound/usb/mixer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,13 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
20142014
bmaControls = ftr->bmaControls;
20152015
}
20162016

2017+
if (channels > 32) {
2018+
usb_audio_info(state->chip,
2019+
"usbmixer: too many channels (%d) in unit %d\n",
2020+
channels, unitid);
2021+
return -EINVAL;
2022+
}
2023+
20172024
/* parse the source unit */
20182025
err = parse_audio_unit(state, hdr->bSourceID);
20192026
if (err < 0)

0 commit comments

Comments
 (0)