Thread (7 messages) flat view 7 messages, 3 authors, 2023-01-29

Re: [PATCH] fbcon: Check font dimension limits

From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: 2023-01-29 15:04:42
Also in: dri-devel, lkml, stable

Jiri Slaby, le jeu. 26 janv. 2023 10:02:55 +0100, a ecrit:
On 26. 01. 23, 1:49, Samuel Thibault wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help