[PATCH v2 3/4] fbmem: Prevent invalid virtual screen sizes in fb_set_var()
Geert Uytterhoeven
geert at linux-m68k.org
Sun Jul 3 08:55:35 UTC 2022
Hi Helge,
On Fri, Jul 1, 2022 at 10:23 PM Helge Deller <deller at gmx.de> wrote:
> Prevent that drivers configure a virtual screen resolution smaller than
> the physical screen resolution. This is important, because otherwise we
> may access memory outside of the graphics memory area.
>
> Give a kernel WARNing and show the driver name to help locating the buggy
> driver.
>
> Signed-off-by: Helge Deller <deller at gmx.de>
> Cc: stable at vger.kernel.org # v5.4+
Thanks for your patch!
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -1016,6 +1016,18 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
> if (ret)
> return ret;
>
> + /* make sure virtual resolution >= physical resolution */
> + if (WARN_ON(var->xres_virtual < var->xres)) {
WARN_ON_ONCE()?
This does mean we would miss two or more buggy drivers in a single system.
> + pr_warn("fbcon: Fix up invalid xres %d for %s\n",
xres_virtual?
> + var->xres_virtual, info->fix.id);
> + var->xres_virtual = var->xres;
I think it's better to not fix this up, but return -EINVAL instead.
After all if we get here, we have a buggy driver that needs to be fixed.
> + }
> + if (WARN_ON(var->yres_virtual < var->yres)) {
> + pr_warn("fbcon: Fix up invalid yres %d for %s\n",
> + var->yres_virtual, info->fix.id);
> + var->yres_virtual = var->yres;
> + }
Same for yres.
> +
> if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
> return 0;
>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-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
More information about the dri-devel
mailing list