summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-07-10 08:57:17 +0200
committerAdrian Stratulat <adrian.stratulat@enea.com>2019-07-12 13:57:45 +0200
commit2ba4140d1fcebcc3606f4ea3b6d0e4ab82be352d (patch)
tree921d14930d2f2a0e0d2dd39f8dc5806700acd1b8
parentdf05b4e3f59ea3400c38c79d414afcc2ba790e58 (diff)
downloadenea-kernel-cache-2ba4140d1fcebcc3606f4ea3b6d0e4ab82be352d.tar.gz
USB: CVE-2018-20169
USB: check usb_get_extra_descriptor for proper size Reference: https://nvd.nist.gov/vuln/detail/CVE-2018-20169 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=fe26b8d06e965239795bee0a71c9073bed931716 Change-Id: I5a596534b24fe2dd83fb2e3779d723eb7b6a4674 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/4.9.x.scc3
-rw-r--r--patches/cve/CVE-2018-20169-USB-check-usb_get_extra_descriptor-for-proper-size.patch107
2 files changed, 110 insertions, 0 deletions
diff --git a/patches/cve/4.9.x.scc b/patches/cve/4.9.x.scc
index 8f097ea..c645a9c 100644
--- a/patches/cve/4.9.x.scc
+++ b/patches/cve/4.9.x.scc
@@ -25,3 +25,6 @@ patch CVE-2018-16871-nfsd-COPY-and-CLONE-operations-require-the-saved-fil.patch
25 25
26#CVEs fixed in 4.9.144: 26#CVEs fixed in 4.9.144:
27patch CVE-2018-18690-xfs-don-t-fail-when-converting-shortform-attr-to-lon.patch 27patch CVE-2018-18690-xfs-don-t-fail-when-converting-shortform-attr-to-lon.patch
28
29#CVEs fixed in 4.9.145:
30patch CVE-2018-20169-USB-check-usb_get_extra_descriptor-for-proper-size.patch
diff --git a/patches/cve/CVE-2018-20169-USB-check-usb_get_extra_descriptor-for-proper-size.patch b/patches/cve/CVE-2018-20169-USB-check-usb_get_extra_descriptor-for-proper-size.patch
new file mode 100644
index 0000000..682d95b
--- /dev/null
+++ b/patches/cve/CVE-2018-20169-USB-check-usb_get_extra_descriptor-for-proper-size.patch
@@ -0,0 +1,107 @@
1From fe26b8d06e965239795bee0a71c9073bed931716 Mon Sep 17 00:00:00 2001
2From: Mathias Payer <mathias.payer@nebelwelt.net>
3Date: Wed, 5 Dec 2018 21:19:59 +0100
4Subject: [PATCH] USB: check usb_get_extra_descriptor for proper size
5
6commit 704620afc70cf47abb9d6a1a57f3825d2bca49cf upstream.
7
8When reading an extra descriptor, we need to properly check the minimum
9and maximum size allowed, to prevent from invalid data being sent by a
10device.
11
12CVE: CVE-2018-20169
13Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=fe26b8d06e965239795bee0a71c9073bed931716]
14
15Reported-by: Hui Peng <benquike@gmail.com>
16Reported-by: Mathias Payer <mathias.payer@nebelwelt.net>
17Co-developed-by: Linus Torvalds <torvalds@linux-foundation.org>
18Signed-off-by: Hui Peng <benquike@gmail.com>
19Signed-off-by: Mathias Payer <mathias.payer@nebelwelt.net>
20Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
21Cc: stable <stable@kernel.org>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
24---
25 drivers/usb/core/hub.c | 2 +-
26 drivers/usb/core/usb.c | 6 +++---
27 drivers/usb/host/hwa-hc.c | 2 +-
28 include/linux/usb.h | 4 ++--
29 4 files changed, 7 insertions(+), 7 deletions(-)
30
31diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
32index 851f5a553de2..67679f619c3b 100644
33--- a/drivers/usb/core/hub.c
34+++ b/drivers/usb/core/hub.c
35@@ -2225,7 +2225,7 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
36 /* descriptor may appear anywhere in config */
37 err = __usb_get_extra_descriptor(udev->rawdescriptors[0],
38 le16_to_cpu(udev->config[0].desc.wTotalLength),
39- USB_DT_OTG, (void **) &desc);
40+ USB_DT_OTG, (void **) &desc, sizeof(*desc));
41 if (err || !(desc->bmAttributes & USB_OTG_HNP))
42 return 0;
43
44diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
45index 891261b43c67..f3996ba71a59 100644
46--- a/drivers/usb/core/usb.c
47+++ b/drivers/usb/core/usb.c
48@@ -696,14 +696,14 @@ EXPORT_SYMBOL_GPL(usb_get_current_frame_number);
49 */
50
51 int __usb_get_extra_descriptor(char *buffer, unsigned size,
52- unsigned char type, void **ptr)
53+ unsigned char type, void **ptr, size_t minsize)
54 {
55 struct usb_descriptor_header *header;
56
57 while (size >= sizeof(struct usb_descriptor_header)) {
58 header = (struct usb_descriptor_header *)buffer;
59
60- if (header->bLength < 2) {
61+ if (header->bLength < 2 || header->bLength > size) {
62 printk(KERN_ERR
63 "%s: bogus descriptor, type %d length %d\n",
64 usbcore_name,
65@@ -712,7 +712,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
66 return -1;
67 }
68
69- if (header->bDescriptorType == type) {
70+ if (header->bDescriptorType == type && header->bLength >= minsize) {
71 *ptr = header;
72 return 0;
73 }
74diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
75index 1db0626c8bf4..97750f162f01 100644
76--- a/drivers/usb/host/hwa-hc.c
77+++ b/drivers/usb/host/hwa-hc.c
78@@ -654,7 +654,7 @@ static int hwahc_security_create(struct hwahc *hwahc)
79 top = itr + itr_size;
80 result = __usb_get_extra_descriptor(usb_dev->rawdescriptors[index],
81 le16_to_cpu(usb_dev->actconfig->desc.wTotalLength),
82- USB_DT_SECURITY, (void **) &secd);
83+ USB_DT_SECURITY, (void **) &secd, sizeof(*secd));
84 if (result == -1) {
85 dev_warn(dev, "BUG? WUSB host has no security descriptors\n");
86 return 0;
87diff --git a/include/linux/usb.h b/include/linux/usb.h
88index eba1f10e8cfd..346665a0c49d 100644
89--- a/include/linux/usb.h
90+++ b/include/linux/usb.h
91@@ -336,11 +336,11 @@ struct usb_host_bos {
92 };
93
94 int __usb_get_extra_descriptor(char *buffer, unsigned size,
95- unsigned char type, void **ptr);
96+ unsigned char type, void **ptr, size_t min);
97 #define usb_get_extra_descriptor(ifpoint, type, ptr) \
98 __usb_get_extra_descriptor((ifpoint)->extra, \
99 (ifpoint)->extralen, \
100- type, (void **)ptr)
101+ type, (void **)ptr, sizeof(**(ptr)))
102
103 /* ----------------------------------------------------------------------- */
104
105--
1062.20.1
107