lkml.org 
[lkml]   [2022]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 0/3] Fix bugs in *_set_par() caused by user input
Hello,

On Thu, Aug 4, 2022 at 10:43 PM Ondrej Zajicek <santiago@crfreenet.org> wrote:
>
> On Thu, Aug 04, 2022 at 08:41:22PM +0800, Zheyu Ma wrote:
> > In the function *_set_par(), the value of 'screen_size' is
> > calculated by the user input. If the user provides the improper value,
> > the value of 'screen_size' may larger than 'info->screen_size', which
> > may cause a bug in the memset_io().
>
> Hi
>
> I did not saw fbdev code in years, but should not this be already checked
> by *_check_var() ?
>
> arkfb_check_var():
>
> ...
> /* Check whether have enough memory */
> mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual;
> if (mem > info->screen_size)
> ...

Thanks for the reminder. But since the user can control all the
parameters of the ioctl system call, it is possible to assign
'var->bits_per_pixel' to be 0 and thus 'mem' will be 0, bypassing this
check. And in *_set_par(), when 'var->bits_per_pixel' is 0,
'screen_size' will be calculated as follows:

u32 bpp = info->var.bits_per_pixel;
if (bpp != 0) {
...
} else {
...
screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64;
}

resulting in a very large value.

regards,

Zheyu Ma

\
 
 \ /
  Last update: 2022-08-05 04:48    [W:0.077 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site