[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMuHMdXRVHiBZj=MQ3jLy2AEnwrvMXt6KXbZXr10ZJMhJDAmsw@mail.gmail.com>
Date: Thu, 11 Aug 2022 13:49:35 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Andrey Strachuk <strochuk@...ras.ru>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>, Helge Deller <deller@....de>,
DRI Development <dri-devel@...ts.freedesktop.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
ldv-project@...uxtesting.org
Subject: Re: [PATCH] drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var()
Hi Andrey,
On Thu, Aug 11, 2022 at 12:23 PM Andrey Strachuk <strochuk@...ras.ru> wrote:
> Add virtual screen size check to drm_fb_helper_check_var() in
> order to validate userspace input.
>
> Found by Linux Verification Center (linuxtesting.org) with syzkaller.
>
> Signed-off-by: Andrey Strachuk <strochuk@...ras.ru>
Thanks for your patch!
> Fixes: 6c11df58fd1a ("fbmem: Check virtual screen sizes in fb_set_var()")
This Fixes tag is misleading: the bug has existed since basically
forever.
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -1355,6 +1355,16 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
> (drm_format_info_block_height(fb->format, 0) > 1))
> return -EINVAL;
>
> + /* verify that virtual resolution >= physical resolution */
> + if (var->xres_virtual < var->xres ||
> + var->yres_virtual < var->yres) {
> + drm_dbg_kms(dev, "requested virtual screen size that is "
> + "below the physical size(%ux%u vs. %ux%u)\n",
> + var->xres_virtual, var->yres_virtual,
> + var->xres, var->yres);
> + return -EINVAL;
According to the fbdev rounding rules, invalid values should be rounded
up, if possible. Hence it is better to not return an error, but round up:
if (var->xres_virtual < var->xres)
var->xres_virtual = var->xres;
if (var->yres_virtual < var->yres)
var->yres_virtual = var->yres;
> + }
> +
> /*
> * Changes struct fb_var_screeninfo are currently not pushed back
> * to KMS, hence fail if different settings are requested.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists