Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: usb-audio: Fix potential out-of-bounds shift

syzbot spotted a potential out-of-bounds shift in the USB-audio format
parser that receives the arbitrary shift value from the USB
descriptor.

Add a range check for avoiding the undefined behavior.

Reported-by: syzbot+df7dc146ebdd6435eea3@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201209084552.17109-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+2
+2
sound/usb/format.c
··· 39 39 case UAC_VERSION_1: 40 40 default: { 41 41 struct uac_format_type_i_discrete_descriptor *fmt = _fmt; 42 + if (format >= 64) 43 + return 0; /* invalid format */ 42 44 sample_width = fmt->bBitResolution; 43 45 sample_bytes = fmt->bSubframeSize; 44 46 format = 1ULL << format;