From: Helge Deller <deller@xxxxxx> commit 65a01e601dbba8b7a51a2677811f70f783766682 upstream. 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@xxxxxx> Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx> Reviewed-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx # v4.14+ Link: https://lore.kernel.org/all/20220706150253.2186-1-deller@xxxxxx/ Signed-off-by: Chen Jun <chenjun102@xxxxxxxxxx> --- drivers/video/console/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 510bc3f51dcc..e9eb8aaa2040 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -2428,6 +2428,11 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne if (charcount != 256 && charcount != 512) return -EINVAL; + /* font bigger than screen resolution ? */ + if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) || + h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) + 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)))) -- 2.17.1