From 5d1cce0111f59cac2e5f27d859806b2e7dcab1bc Mon Sep 17 00:00:00 2001 From: Andreas Wellving Date: Wed, 22 May 2019 11:19:00 +0200 Subject: USB: CVE-2018-16276 USB: yurex: fix out-of-bounds uaccess in read handler Reference: https://nvd.nist.gov/vuln/detail/CVE-2018-16276 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=90f2a76ccd37cce2530df49335bcea6cd0e23797 Change-Id: Ie5e54d7049bd414a22d458364f2965ccc6ca8e3d Signed-off-by: Andreas Wellving --- ...fix-out-of-bounds-uaccess-in-read-handler.patch | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 patches/cve/CVE-2018-16276-USB-yurex-fix-out-of-bounds-uaccess-in-read-handler.patch (limited to 'patches/cve') 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 @@ +From 90f2a76ccd37cce2530df49335bcea6cd0e23797 Mon Sep 17 00:00:00 2001 +From: Jann Horn +Date: Fri, 6 Jul 2018 17:12:56 +0200 +Subject: [PATCH] USB: yurex: fix out-of-bounds uaccess in read handler + +commit f1e255d60ae66a9f672ff9a207ee6cd8e33d2679 upstream. + +In general, accessing userspace memory beyond the length of the supplied +buffer in VFS read/write handlers can lead to both kernel memory corruption +(via kernel_read()/kernel_write(), which can e.g. be triggered via +sys_splice()) and privilege escalation inside userspace. + +Fix it by using simple_read_from_buffer() instead of custom logic. + +CVE: CVE-2018-16276 +Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=90f2a76ccd37cce2530df49335bcea6cd0e23797] + +Fixes: 6bc235a2e24a ("USB: add driver for Meywa-Denki & Kayac YUREX") +Signed-off-by: Jann Horn +Cc: stable +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Andreas Wellving +--- + drivers/usb/misc/yurex.c | 23 ++++++----------------- + 1 file changed, 6 insertions(+), 17 deletions(-) + +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c +index 58abdf28620a..47763311a42e 100644 +--- a/drivers/usb/misc/yurex.c ++++ b/drivers/usb/misc/yurex.c +@@ -400,8 +400,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, + loff_t *ppos) + { + struct usb_yurex *dev; +- int retval = 0; +- int bytes_read = 0; ++ int len = 0; + char in_buffer[20]; + unsigned long flags; + +@@ -409,26 +408,16 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, + + mutex_lock(&dev->io_mutex); + if (!dev->interface) { /* already disconnected */ +- retval = -ENODEV; +- goto exit; ++ mutex_unlock(&dev->io_mutex); ++ return -ENODEV; + } + + spin_lock_irqsave(&dev->lock, flags); +- bytes_read = snprintf(in_buffer, 20, "%lld\n", dev->bbu); ++ len = snprintf(in_buffer, 20, "%lld\n", dev->bbu); + spin_unlock_irqrestore(&dev->lock, flags); +- +- if (*ppos < bytes_read) { +- if (copy_to_user(buffer, in_buffer + *ppos, bytes_read - *ppos)) +- retval = -EFAULT; +- else { +- retval = bytes_read - *ppos; +- *ppos += bytes_read; +- } +- } +- +-exit: + mutex_unlock(&dev->io_mutex); +- return retval; ++ ++ return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); + } + + static ssize_t yurex_write(struct file *file, const char __user *user_buffer, +-- +2.20.1 + -- cgit v1.2.3-54-g00ecf