Re: [syzbot] [sound?] [usb?] UBSAN: shift-out-of-bounds in parse_audio_unit

From: Edward Adam Davis
Date: Tue Jul 16 2024 - 03:05:51 EST


bLength too small ?

#syz test: upstream a19ea421490d

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 409fc1164694..cc92c989a772 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1999,6 +1999,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,

if (state->mixer->protocol == UAC_VERSION_1) {
csize = hdr->bControlSize;
+ printk("c: %d, bLen: %d, %c, \n", channels, hdr->bLength, hdr->bLength, __func__ );
+ if (hdr->bLength < 7)
+ return -EINVAL;
channels = (hdr->bLength - 7) / csize - 1;
bmaControls = hdr->bmaControls;
} else if (state->mixer->protocol == UAC_VERSION_2) {