dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alan Mackenzie" <acm@muc.de>
Cc: linux-serial@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [Patch 7/9]: vt: Handle up to 2^21 glyphs, rather than 256/512
Date: Thu, 27 Aug 2026 19:14:38 +0000	[thread overview]
Message-ID: <20260827191439.4A0341F000E9@smtp.kernel.org> (raw)
In-Reply-To: <apCH8Pt7qdDjUWuW@MAC.fritz.box>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The intended support for large 21-bit fonts is functionally broken, and allocations near the 4MB boundary trigger a kernel warning.
--

commit 0f8b2aafff067c8299c320bab75fcb965a117b84
Author: Alan Mackenzie <acm@muc.de>

vt: Handle up to 2^21 glyphs, rather than 256/512

This commit increases the maximum number of font glyphs supported by the
vt subsystem to 2^21 to supplement tests with full Unicode limits.

> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 9208970f731e0..baf7c98429e9c 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
[ ... ]
> @@ -5015,17 +5016,23 @@ static int con_font_set(struct vc_data *vc, const struct console_font_op *op)
[ ... ]
>  	size = DIV_ROUND_UP(op->width, 8) * vpitch * op->charcount;
> +#ifndef CONFIG_FB_GLYPH_21BIT
>  	if (size > max_font_size)
>  		return -ENOSPC;
> -
> +#endif
>  	void *font_data __free(kfree) = font.data = memdup_user(op->data, size);

[Severity: High]
Will memdup_user() reliably handle the newly permitted size allocations?

Because memdup_user() relies on kmalloc(), it is bounded to allocations
up to 4MB (MAX_PAGE_ORDER). If a user requests a font with 2^21 glyphs, the
size could easily exceed this limit, causing the allocation to silently fail
with -ENOMEM. 

Would it be better to use vmemdup_user() here to fully support the larger
21-bit limit?

> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index 576be479d9286..a610071c89f53 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
[ ... ]
> @@ -2525,10 +2531,18 @@ static int fbcon_set_font(struct vc_data *vc, const struct console_font *font,
>  	int i, ret;
>  	font_data_t *new_data;
>  
> -	/* Is there a reason why fbconsole couldn't handle any charcount >256?
> -	 * If not this check should be changed to charcount < 256 */
> +#ifdef CONFIG_FB_GLYPH_21BIT
> +	if (charcount < 256)
> +		return -EINVAL;

[Severity: High]
Does this relaxed limit expose a kernel warning crash vector in the page
allocator?

By allowing charcount to reach 2^21, font allocations can approach or exactly
hit the 4MB limit. When font_data_import() is called later in this function
with these parameters, it does the following:

lib/fonts/fonts.c:font_data_import() {
    ...
    alloc_size = size + sizeof(*font_data);
    font_data = kmalloc(alloc_size, GFP_USER);
    ...
}

If a user with CAP_SYS_TTY_CONFIG configures a font where the requested size
is exactly 4MB (which passes the memdup_user() check in con_font_set()), the
addition of sizeof(*font_data) will push the alloc_size slightly over 4MB. 

Since this kmalloc() lacks the __GFP_NOWARN flag and requires an order 11
allocation, it will trigger a WARN_ON_ONCE in the page allocator. This could
crash systems configured with panic_on_warn.

> +#else
> +	/* There is no longer any reason why fbconsole can't handle
> +	 * any charcount >256, when CONFIG_FB_GLYPH_21BIT is #defined.
> +	 * Hence this check has been changed to charcount < 256
> +	 * above.
> +	 */
>  	if (charcount != 256 && charcount != 512)
>  		return -EINVAL;
> +#endif

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/apCEDM2sWv_M354-@MAC.fritz.box?part=7

  reply	other threads:[~2026-08-27 19:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 18:38 vt: Enlarge the framebuffer glyph size from 16 to 32 bits Alan Mackenzie
2026-08-27 18:42 ` [Patch 1/9]: Make consolemap.c handle Unicode planes outside BMP Alan Mackenzie
2026-08-27 19:14   ` sashiko-bot
2026-08-28  4:57   ` Jiri Slaby
2026-08-29 11:51     ` Alan Mackenzie
2026-08-27 18:45 ` [Patch 2/9]: Glyph size: Use GLYPH_SZ/HW rather than hardcoded 2, 1 Alan Mackenzie
2026-08-27 19:22   ` sashiko-bot
2026-08-27 18:47 ` [Patch 3/9]: Replace scr_readw/writew by scr_readg/writeg, etc Alan Mackenzie
2026-08-27 19:18   ` sashiko-bot
2026-08-29 12:11   ` Greg Kroah-Hartman
2026-08-29 13:33     ` Alan Mackenzie
2026-08-27 18:48 ` [Patch 4/9]: Amend internal manipulation of glyph structure Alan Mackenzie
2026-08-27 19:19   ` sashiko-bot
2026-08-27 18:50 ` [Patch 5/9]: vt: Amend three Kconfig files Alan Mackenzie
2026-08-27 19:12   ` sashiko-bot
2026-08-27 18:52 ` [Patch 6/9]: vt: Use u32 and typedef u1632 to handle whole glyphs Alan Mackenzie
2026-08-27 19:22   ` sashiko-bot
2026-08-27 18:54 ` [Patch 7/9]: vt: Handle up to 2^21 glyphs, rather than 256/512 Alan Mackenzie
2026-08-27 19:14   ` sashiko-bot [this message]
2026-08-27 18:56 ` [Patch 8/9]: vt: Enhancements to the VT ioctl interface Alan Mackenzie
2026-08-27 19:25   ` sashiko-bot
2026-08-27 18:58 ` [Patch 9/9]: vt: Misc changes, e.g. to #include directives Alan Mackenzie
2026-08-27 19:25   ` sashiko-bot
2026-08-29 12:06   ` Greg Kroah-Hartman
2026-08-28  6:12 ` vt: Enlarge the framebuffer glyph size from 16 to 32 bits Thomas Zimmermann
2026-08-28 14:36   ` Alan Mackenzie
2026-08-29 12:09     ` Greg Kroah-Hartman
2026-08-29 14:39       ` Alan Mackenzie
2026-08-31  6:20         ` Thomas Zimmermann
2026-08-31 14:45           ` Alan Mackenzie
2026-08-31 17:21             ` Helge Deller
2026-09-01 11:14               ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260827191439.4A0341F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acm@muc.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox