USB: fix out-of-bounds in usb_set_configuration 90/179690/2
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2017 13:07:17 +0000 (15:07 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 24 May 2018 04:20:26 +0000 (13:20 +0900)
commita176b12172d505995cf957c6487d1eaf88ff686b
treea610f3ebdfd30ae3fefec994060cf6b35020c36c
parentaa638b973a13601c3d28145e5f2aafc8544d6f4f
USB: fix out-of-bounds in usb_set_configuration

commit bd7a3fe770ebd8391d1c7d072ff88e9e76d063eb upstream.

Andrey Konovalov reported a possible out-of-bounds problem for a USB interface
association descriptor.  He writes:
It seems there's no proper size check of a USB_DT_INTERFACE_ASSOCIATION
descriptor. It's only checked that the size is >= 2 in
usb_parse_configuration(), so find_iad() might do out-of-bounds access
to intf_assoc->bInterfaceCount.

And he's right, we don't check for crazy descriptors of this type very well, so
resolve this problem.  Yet another issue found by syzkaller...

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[sw0312.kim: cherry-pick from linux-3.16.y to fix CVE-2017-16531]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I2413801c6cf5e9eeda0280ba859466d01f5fd9d9
drivers/usb/core/config.c
include/uapi/linux/usb/ch9.h