summaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2019-05-13 13:14:29 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-09 09:17:12 +0200
commita43bb9e83155e0dbf057f8818335cfceae5b075e (patch)
tree79e1039e00f10051d9aa2c94befdda44af8651e5 /drivers/usb/core
parent2fc485b0008e5aa7e62bed4e61aa240808f95aed (diff)
downloadlinux-stable-a43bb9e83155e0dbf057f8818335cfceae5b075e.tar.gz
linux-stable-a43bb9e83155e0dbf057f8818335cfceae5b075e.tar.bz2
linux-stable-a43bb9e83155e0dbf057f8818335cfceae5b075e.zip
USB: Fix slab-out-of-bounds write in usb_get_bos_descriptor
commit a03ff54460817c76105f81f3aa8ef655759ccc9a upstream. The syzkaller USB fuzzer found a slab-out-of-bounds write bug in the USB core, caused by a failure to check the actual size of a BOS descriptor. This patch adds a check to make sure the descriptor is at least as large as it is supposed to be, so that the code doesn't inadvertently access memory beyond the end of the allocated region when assigning to dev->bos->desc->bNumDeviceCaps later on. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-and-tested-by: syzbot+71f1e64501a309fcc012@syzkaller.appspotmail.com CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/config.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 7b5cb28ffb35..e723ddd79bcf 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -936,8 +936,8 @@ int usb_get_bos_descriptor(struct usb_device *dev)
/* Get BOS descriptor */
ret = usb_get_descriptor(dev, USB_DT_BOS, 0, bos, USB_DT_BOS_SIZE);
- if (ret < USB_DT_BOS_SIZE) {
- dev_err(ddev, "unable to get BOS descriptor\n");
+ if (ret < USB_DT_BOS_SIZE || bos->bLength < USB_DT_BOS_SIZE) {
+ dev_err(ddev, "unable to get BOS descriptor or descriptor too short\n");
if (ret >= 0)
ret = -ENOMSG;
kfree(bos);