diff options
-rw-r--r-- | patches/cve/CVE-2018-16276-USB-yurex-fix-out-of-bounds-uaccess-in-read-handler.patch | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/patches/cve/CVE-2018-16276-USB-yurex-fix-out-of-bounds-uaccess-in-read-handler.patch b/patches/cve/CVE-2018-16276-USB-yurex-fix-out-of-bounds-uaccess-in-read-handler.patch new file mode 100644 index 0000000..62b5e11 --- /dev/null +++ b/patches/cve/CVE-2018-16276-USB-yurex-fix-out-of-bounds-uaccess-in-read-handler.patch | |||
@@ -0,0 +1,75 @@ | |||
1 | From 90f2a76ccd37cce2530df49335bcea6cd0e23797 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jann Horn <jannh@google.com> | ||
3 | Date: Fri, 6 Jul 2018 17:12:56 +0200 | ||
4 | Subject: [PATCH] USB: yurex: fix out-of-bounds uaccess in read handler | ||
5 | |||
6 | commit f1e255d60ae66a9f672ff9a207ee6cd8e33d2679 upstream. | ||
7 | |||
8 | In general, accessing userspace memory beyond the length of the supplied | ||
9 | buffer in VFS read/write handlers can lead to both kernel memory corruption | ||
10 | (via kernel_read()/kernel_write(), which can e.g. be triggered via | ||
11 | sys_splice()) and privilege escalation inside userspace. | ||
12 | |||
13 | Fix it by using simple_read_from_buffer() instead of custom logic. | ||
14 | |||
15 | CVE: CVE-2018-16276 | ||
16 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=90f2a76ccd37cce2530df49335bcea6cd0e23797] | ||
17 | |||
18 | Fixes: 6bc235a2e24a ("USB: add driver for Meywa-Denki & Kayac YUREX") | ||
19 | Signed-off-by: Jann Horn <jannh@google.com> | ||
20 | Cc: stable <stable@vger.kernel.org> | ||
21 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
22 | Signed-off-by: Andreas Wellving <andreas.wellving@enea.com> | ||
23 | --- | ||
24 | drivers/usb/misc/yurex.c | 23 ++++++----------------- | ||
25 | 1 file changed, 6 insertions(+), 17 deletions(-) | ||
26 | |||
27 | diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c | ||
28 | index 58abdf28620a..47763311a42e 100644 | ||
29 | --- a/drivers/usb/misc/yurex.c | ||
30 | +++ b/drivers/usb/misc/yurex.c | ||
31 | @@ -400,8 +400,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, | ||
32 | loff_t *ppos) | ||
33 | { | ||
34 | struct usb_yurex *dev; | ||
35 | - int retval = 0; | ||
36 | - int bytes_read = 0; | ||
37 | + int len = 0; | ||
38 | char in_buffer[20]; | ||
39 | unsigned long flags; | ||
40 | |||
41 | @@ -409,26 +408,16 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, | ||
42 | |||
43 | mutex_lock(&dev->io_mutex); | ||
44 | if (!dev->interface) { /* already disconnected */ | ||
45 | - retval = -ENODEV; | ||
46 | - goto exit; | ||
47 | + mutex_unlock(&dev->io_mutex); | ||
48 | + return -ENODEV; | ||
49 | } | ||
50 | |||
51 | spin_lock_irqsave(&dev->lock, flags); | ||
52 | - bytes_read = snprintf(in_buffer, 20, "%lld\n", dev->bbu); | ||
53 | + len = snprintf(in_buffer, 20, "%lld\n", dev->bbu); | ||
54 | spin_unlock_irqrestore(&dev->lock, flags); | ||
55 | - | ||
56 | - if (*ppos < bytes_read) { | ||
57 | - if (copy_to_user(buffer, in_buffer + *ppos, bytes_read - *ppos)) | ||
58 | - retval = -EFAULT; | ||
59 | - else { | ||
60 | - retval = bytes_read - *ppos; | ||
61 | - *ppos += bytes_read; | ||
62 | - } | ||
63 | - } | ||
64 | - | ||
65 | -exit: | ||
66 | mutex_unlock(&dev->io_mutex); | ||
67 | - return retval; | ||
68 | + | ||
69 | + return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); | ||
70 | } | ||
71 | |||
72 | static ssize_t yurex_write(struct file *file, const char __user *user_buffer, | ||
73 | -- | ||
74 | 2.20.1 | ||
75 | |||