Thread (11 messages) 11 messages, 2 authors, 2022-07-04

Re: [PATCH v2 3/4] fbmem: Prevent invalid virtual screen sizes in fb_set_var()

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2022-07-04 16:16:37
Also in: dri-devel

Hi Helge,

On Fri, Jul 1, 2022 at 10:23 PM Helge Deller [off-list ref] 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@gmx.de>
Cc: stable@vger.kernel.org # v5.4+
Thanks for your patch!
quoted hunk ↗ jump to hunk
--- 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@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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help