Re: [PATCH] fbcon: Check font dimension limits

From: Samuel Thibault
Date: Sun Jan 29 2023 - 10:04:42 EST


Jiri Slaby, le jeu. 26 janv. 2023 10:02:55 +0100, a ecrit:
> On 26. 01. 23, 1:49, Samuel Thibault wrote:
> > Index: linux-6.0/drivers/video/fbdev/core/fbcon.c
> > ===================================================================
> > --- linux-6.0.orig/drivers/video/fbdev/core/fbcon.c
> > +++ linux-6.0/drivers/video/fbdev/core/fbcon.c
> > @@ -2489,9 +2489,12 @@ static int fbcon_set_font(struct vc_data
> > h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres))
> > return -EINVAL;
> > + if (font->width > 32 || font->height > 32)
> > + 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))))
> > + if (!(info->pixmap.blit_x & (1U << (font->width - 1))) ||
> > + !(info->pixmap.blit_y & (1U << (font->height - 1))))
>
> So use BIT() properly then? That should be used in all these shifts anyway.
> Exactly to avoid UB.

Right, I'll use that in next version.

Samuel