All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yao Yiqi" <yaoyiqi3@huawei.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] fbcon: Rebuild rotated font buffer on font change
Date: Wed, 14 Oct 2026 09:35:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-171079@kernel.org> (raw)
In-Reply-To: <20261014085102.497789-1-yaoyiqi3@huawei.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] fbcon: dangling pointer in par->rotated.fontdata causes ABA vulnerability
- [High] fbcon: OOB read and UAF in fbcon_do_set_font error path
--

commit 40ac874a29ca63690bb8c7dfaad9a195bb52891d
Author: Yao Yiqi <yaoyiqi3@huawei.com>

fbcon: Rebuild rotated font buffer on font change

fbcon_rotate_font() caches a rotated copy of the console font in
par->rotated.buf. This commit fixes a slab-out-of-bounds read in
fbcon when changing the console font by explicitly rebuilding the
rotated font buffer before the redraw is triggered.

> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index 615fa596b7cce..caad4e06944ea 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -2431,6 +2431,17 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,
>  	else if (!vc->vc_hi_font_mask && charcount == 512)
>  		set_vc_hi_font(vc, true);
>  
> +	/*
> +	 * The rotated font buffer is sized from the new font's width, height
> +	 * and charcount. Rebuild it for the visible console before the redraw
> +	 * below, as fbcon_switch() and fbcon_modechanged() already do. The
> +	 * redraw reaches the rotated bitops through hide_cursor(), and those
> +	 * index the buffer with the new cell size and character codes, so a
> +	 * stale, too-small buffer is read out of bounds.
> +	 */
> +	if (con_is_visible(vc) && par->bitops->rotate_font)
> +		par->bitops->rotate_font(info, vc);
> +

[Severity: High]
If vc_resize() fails below this point (e.g., due to -ENOMEM from screen buffer
allocation), the err_out path reverts the console font metrics but leaves the
rotated buffer and pointer out of sync.

Could this leave par->rotated.buf sized for the new font, while the font
metrics are restored to the old font? If a subsequent call uses a smaller font,
the buffer could be allocated exactly to the smaller size. If vc_resize() then
fails, the metrics are restored to the larger font, which could cause a
slab-out-of-bounds read during subsequent redraws (such as cursor blink).

Furthermore, the err_out path drops the new font's refcount via
font_data_put(data), and the memory is subsequently freed by the caller.

Does this leave par->rotated.fontdata as a dangling pointer to this freed
memory? 

If a future font allocation reuses this exact slab address, the ABA logic in
fbcon_rotate_font():

	if (par->p->fontdata == par->rotated.fontdata &&
	    par->rotate == par->rotated.buf_rotate)
		return 0;

would incorrectly assume the font hasn't changed and skip rebuilding the
buffer, perpetuating the metric mismatch and leading to further out-of-bounds
accesses.

>  	if (resize) {
>  		int cols, rows;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014085102.497789-1-yaoyiqi3@huawei.com?part=1

      parent reply	other threads:[~2026-10-14  9:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  8:51 [PATCH 1/2] fbcon: Rebuild rotated font buffer on font change Yao Yiqi
2026-10-14  8:51 ` [PATCH 2/2] fbcon: Retry rotated font allocation after failure Yao Yiqi
2026-10-14  9:33   ` sashiko-bot
2026-10-14  9:35 ` sashiko-bot [this message]

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=sashiko-outbox-171079@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yaoyiqi3@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.