patch "USB: yurex: fix out-of-bounds uaccess in read handler" added to usb-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
USB: yurex: fix out-of-bounds uaccess in read handler
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
Quoted 1 line
From
f1e255d60ae66a9f672ff9a207ee6cd8e33d2679Mon Sep 17 00:00:00 2001
From: Jann Horn <[email protected]>
Date: Fri, 6 Jul 2018 17:12:56 +0200
Subject: USB: yurex: fix out-of-bounds uaccess in read handler
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.
--- drivers/usb/misc/yurex.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
drivers/usb/misc/yurex.c +6 -17
@@ -396,8 +396,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;
@@ -405,26 +404,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,
Signature · 1 line
2.18.0