USB: core: Add type-specific length check of BOS descriptors 93/179693/2 accepted/tizen/unified/20180619.141837 submit/tizen/20180615.023254
authorMasakazu Mokuno <masakazu.mokuno@gmail.com>
Thu, 9 Nov 2017 16:25:50 +0000 (01:25 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 24 May 2018 04:20:28 +0000 (13:20 +0900)
commita2a42ed7a8eb2ecdea45d2d3d8c8a1034565ba02
tree956d6bd7c333c71f5b8dd123433f7c41960deb3e
parent03680e23a5cafcda08d117b8dfa2728bcca2231d
USB: core: Add type-specific length check of BOS descriptors

commit 81cf4a45360f70528f1f64ba018d61cb5767249a upstream.

As most of BOS descriptors are longer in length than their header
'struct usb_dev_cap_header', comparing solely with it is not sufficient
to avoid out-of-bounds access to BOS descriptors.

This patch adds descriptor type specific length check in
usb_get_bos_descriptor() to fix the issue.

Signed-off-by: Masakazu Mokuno <masakazu.mokuno@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.16: drop handling of USB_PTM_CAP_TYPE and USB_SSP_CAP_TYPE]
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: Id446c97db292f11c48895b95e756bb0c7104a43b
drivers/usb/core/config.c
include/uapi/linux/usb/ch9.h