[PATCH 1/5] fbcon: Disallow setting font bigger than screen size

Geert Uytterhoeven geert at linux-m68k.org
Thu Jun 30 18:51:29 UTC 2022


Hi Helge,

On Wed, Jun 29, 2022 at 10:00 PM Helge Deller <deller at gmx.de> wrote:
> Prevent that users set a font size which is bigger than the physical screen.
> It's unlikely this may happen (because screens are usually much larger than the
> fonts and each font char is limited to 32x32 pixels), but it may happen on
> smaller screens/LCD displays.
>
> Signed-off-by: Helge Deller <deller at gmx.de>
> Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert at linux-m68k.org>

> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -2469,6 +2469,11 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
>         if (charcount != 256 && charcount != 512)
>                 return -EINVAL;
>
> +       /* font bigger than screen resolution ? */
> +       if (font->width  > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) ||
> +           font->height > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres))

Note that we already have local vars w and h, albeit with the wrong
signedness.

> +               return -EINVAL;
> +
>         /* Make sure drawing engine can handle the font */
>         if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
>             !(info->pixmap.blit_y & (1 << (font->height - 1))))

There were already more opportunities for using w and h before...

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