USB: core: prevent malicious bNumInterfaces overflow 92/179692/2
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 12 Dec 2017 19:25:13 +0000 (14:25 -0500)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 24 May 2018 04:20:27 +0000 (13:20 +0900)
commit03680e23a5cafcda08d117b8dfa2728bcca2231d
tree7d0ef3326ab0d1104a3b67108c67eeca0ec8c95b
parent7769c0e21d84feed08b18df627432d8e541c242d
USB: core: prevent malicious bNumInterfaces overflow

commit 48a4ff1c7bb5a32d2e396b03132d20d552c0eca7 upstream.

A malicious USB device with crafted descriptors can cause the kernel
to access unallocated memory by setting the bNumInterfaces value too
high in a configuration descriptor.  Although the value is adjusted
during parsing, this adjustment is skipped in one of the error return
paths.

This patch prevents the problem by setting bNumInterfaces to 0
initially.  The existing code already sets it to the proper value
after parsing is complete.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-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 usb issue related with CVE-2017-16531]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Id256d4802f9db3013b7abcc19652304e1c5a2b2f
drivers/usb/core/config.c