lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 3 Jul 2018 09:50:16 +0200
From:   Benjamin Tissoires <benjamin.tissoires@...hat.com>
To:     Daniel Rosenberg <drosen@...gle.com>
Cc:     Jiri Kosina <jikos@...nel.org>,
        "open list:HID CORE LAYER" <linux-input@...r.kernel.org>,
        lkml <linux-kernel@...r.kernel.org>, kernel-team@...roid.com,
        "3.8+" <stable@...r.kernel.org>
Subject: Re: [PATCH] HID: debug: check length before copy_to_user()

On Tue, Jul 3, 2018 at 1:59 AM, Daniel Rosenberg <drosen@...gle.com> wrote:
> If our length is greater than the size of the buffer, we
> overflow the buffer
>
> Signed-off-by: Daniel Rosenberg <drosen@...gle.com>
> Cc: stable@...r.kernel.org
> ---

Looks good:
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@...hat.com>

Cheers,
Benjamin

>  drivers/hid/hid-debug.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> index 8469b6964ff64..b48100236df89 100644
> --- a/drivers/hid/hid-debug.c
> +++ b/drivers/hid/hid-debug.c
> @@ -1154,6 +1154,8 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
>                         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 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
>                         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 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
>                         }
>                         list->head = 0;
>                         ret += len;
> -                       goto copy_rest;
> +                       count -= len;
> +                       if (count > 0)
> +                               goto copy_rest;
>                 }
>
>         }
> --
> 2.18.0.399.gad0ab374a1-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ