lkml.org 
[lkml]   [2018]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 33/53] HID: debug: check length before copy_to_user()
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Daniel Rosenberg <drosen@google.com>

    commit 717adfdaf14704fd3ec7fa2c04520c0723247eac upstream.

    If our length is greater than the size of the buffer, we
    overflow the buffer

    Cc: stable@vger.kernel.org
    Signed-off-by: Daniel Rosenberg <drosen@google.com>
    Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/hid/hid-debug.c | 8 +++++++-
    1 file changed, 7 insertions(+), 1 deletion(-)

    --- a/drivers/hid/hid-debug.c
    +++ b/drivers/hid/hid-debug.c
    @@ -1154,6 +1154,8 @@ copy_rest:
    goto out;
    if (list->tail > list->head) {
    len = list->tail - list->head;
    + if (len > count)
    + len = count;

    if (copy_to_user(buffer + ret, &list->hid_debug_buf[list->head], len)) {
    ret = -EFAULT;
    @@ -1163,6 +1165,8 @@ copy_rest:
    list->head += len;
    } else {
    len = HID_DEBUG_BUFSIZE - list->head;
    + if (len > count)
    + len = count;

    if (copy_to_user(buffer, &list->hid_debug_buf[list->head], len)) {
    ret = -EFAULT;
    @@ -1170,7 +1174,9 @@ copy_rest:
    }
    list->head = 0;
    ret += len;
    - goto copy_rest;
    + count -= len;
    + if (count > 0)
    + goto copy_rest;
    }

    }

    \
     
     \ /
      Last update: 2018-07-10 20:45    [W:4.022 / U:0.440 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site