lkml.org 
[lkml]   [2019]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: stm class: Prevent user-controllable allocations
On Tue, May 07, 2019 at 02:41:13PM +0200, Pavel Machek wrote:
>
> It seems to me that we still allow overflow if count == ~0. We'll then
> allocate 0 bytes but copy ~0 bytes. That does not sound healthy.
>
> Fixes: f08b18266c7116e2ec6885dd53a928f580060a71
>
> Signed-off-by: Pavel Machek <pavel@denx.de>
>
> diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
> index c7ba8ac..8846fca 100644
> --- a/drivers/hwtracing/stm/core.c
> +++ b/drivers/hwtracing/stm/core.c
> @@ -631,7 +631,7 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,
> char *kbuf;
> int err;
>
> - if (count + 1 > PAGE_SIZE)
> + if (count > PAGE_SIZE - 1)
> count = PAGE_SIZE - 1;

The "count" variable should all be checked in vfs_write(). count + off
is checked in rw_verify_area() and count is capped at MAX_RW_COUNT.

#define MAX_RW_COUNT (INT_MAX & PAGE_MASK)

regards,
dan carpenter

\
 
 \ /
  Last update: 2019-05-07 14:53    [W:0.032 / U:2.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site