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 2/2] fbcon: Retry rotated font allocation after failure
Date: Wed, 14 Oct 2026 09:33:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-171078@kernel.org> (raw)
In-Reply-To: <20261014085102.497789-2-yaoyiqi3@huawei.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] fbcon: OOB read via dimension-swapped font loading
- [Medium] fbcon: broken fallback to unrotated rendering on rotate_font failure
--

commit 1bccc1e9cd74782edba7f76b0ad2e196a29fd948
Author: Yao Yiqi <yaoyiqi3@huawei.com>

fbcon: Retry rotated font allocation after failure

fbcon_rotate_font() records the font and rotation it is about to handle in
par->rotated.fontdata and par->rotated.buf_rotate before calling
font_data_rotate(). If that allocation fails it clears par->rotated.buf,
but the cached font/rotation state already looks up to date, so the next
call takes the early-out and never retries.

Fixes: e4ef723d8975 ("fbcon: Avoid OOB font access if console rotation fails")
Cc: stable@vger.kernel.org

> The rotated putcs/cursor ops keep returning early on the NULL buffer and
> the console stays blank until the font or the rotation is changed, even
> once memory is available again.

[Severity: Medium]
Is the fallback to unrotated rendering on rotate_font() failure broken?

When par->bitops->rotate_font() fails, existing callers attempt to fall back
to unrotated rendering:

drivers/video/fbdev/core/fbcon.c:fbcon_init() {
    ...
	if (par->bitops->rotate_font && par->bitops->rotate_font(info, vc)) {
		par->rotate = FB_ROTATE_UR;
		set_blitting_type(vc, info);
	}
    ...
}

But set_blitting_type() invokes fbcon_set_rotation() unconditionally, which
overwrites the fallback state back to the originally requested rotation:

drivers/video/fbdev/core/fbcon.c:fbcon_set_rotation() {
    ...
	if (!(info->flags & FBINFO_MISC_TILEBLITTING) &&
	    par->p->con_rotate < 4)
		par->rotate = par->p->con_rotate;
    ...
}

Because the bitops are left as rotated, and par->rotated.buf is NULL, all
drawing operations abort and the screen remains completely blank:

drivers/video/fbdev/core/fbcon_ccw.c:ccw_putcs() {
    ...
	if (!par->rotated.buf)
		return;
    ...
}

Also, it appears the call to rotate_font() in fbcon_do_set_font() ignores
its return value entirely:

drivers/video/fbdev/core/fbcon.c:fbcon_do_set_font() {
    ...
	if (con_is_visible(vc) && par->bitops->rotate_font)
		par->bitops->rotate_font(info, vc);
    ...
}

> diff --git a/drivers/video/fbdev/core/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c
> index 6cdbc96eeca6f..6b148e0e81e66 100644
> --- a/drivers/video/fbdev/core/fbcon_rotate.c
> +++ b/drivers/video/fbdev/core/fbcon_rotate.c
> @@ -21,7 +21,9 @@ int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
>  	unsigned char *buf;
>  	int ret;
>  
> -	if (par->p->fontdata == par->rotated.fontdata && par->rotate == par->rotated.buf_rotate)
> +	if (par->p->fontdata == par->rotated.fontdata &&
> +	    par->rotate == par->rotated.buf_rotate &&
> +	    par->rotated.buf)
>  		return 0;

[Severity: High]
Does this early return still rely only on the fontdata pointer?

If a new font shares the same raw byte array (reused via font_data_is_equal)
but has different dimensions, it looks like it could bypass rotated buffer
reallocation because the fontdata pointer remains the same.

Rendering operations could then use the new, larger cellsize to index the
un-updated rotated buffer, resulting in an out-of-bounds read:

drivers/video/fbdev/core/fbcon_cw.c:cw_putcs_aligned() {
    ...
	src = par->rotated.buf + (scr_readw(s++) & charmask) * cellsize;
    ...
}

>  
>  	par->rotated.fontdata = par->p->fontdata;

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

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

Thread overview: 5+ 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 [this message]
2026-10-14  9:35 ` [PATCH 1/2] fbcon: Rebuild rotated font buffer on font change sashiko-bot
2026-10-14 19:58 ` Helge Deller

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-171078@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.