[PATCH 1/5] fbcon: Disallow setting font bigger than screen size
Helge Deller
deller at gmx.de
Thu Jun 30 19:26:08 UTC 2022
On 6/30/22 20:51, Geert Uytterhoeven wrote:
> 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.
I don't like the "h" and "w" variables. Maybe something like "fh" for "font-heigth"
would have been better explaining which kind of "h" is meant.
I assume that's why the patch below didn't used it either.
That said, I'd like to keep it as is (at least for now).
Helge
>> + 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