ALSA: usb-audio: Always check descriptor sizes in parser code
authorTakashi Iwai <tiwai@suse.de>
Wed, 2 Jan 2019 16:12:21 +0000 (17:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Jan 2019 08:51:06 +0000 (09:51 +0100)
commit378f9dfa495a548cbc87173477d8c4b8cbea8826
treeff4cafab43a18ee569856d8335424e73257aac04
parent6c8c16479b2363972d02bc6a4be132a9a9acd17e
ALSA: usb-audio: Always check descriptor sizes in parser code

commit 3e96d7280f16e2f787307f695a31296b9e4a1cd7 upstream.

There are a few places where we access the data without checking the
actual object size from the USB audio descriptor.  This may result in
OOB access, as recently reported.

This patch addresses these missing checks.  Most of added codes are
simple bLength checks in the caller side.  For the input and output
terminal parsers, we put the length check in the parser functions.
For the input terminal, a new argument is added to distinguish between
UAC1 and the rest, as they treat different objects.

Reported-by: Mathias Payer <mathias.payer@nebelwelt.net>
Reported-by: Hui Peng <benquike@163.com>
Tested-by: Hui Peng <benquike@163.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/usb/card.c
sound/usb/mixer.c
sound/usb/stream.c