From: sashiko-bot@kernel.org
To: "Rik van Riel" <riel@surriel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] fbdev: bitblit: bound-check glyph index in bit_cursor()
Date: Sat, 08 Aug 2026 02:46:48 +0000 [thread overview]
Message-ID: <20260808024649.F07761F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807221956.4e9dde5c@fangorn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The bounds checking for glyph indices is missing in software rotation paths (fbcon_ccw.c, fbcon_cw.c, fbcon_ud.c), leaving them vulnerable to out-of-bounds heap reads.
--
--- Patch [1]: [PATCH] fbdev: bitblit: bound-check glyph index in bit_cursor() ---
commit eb8c6b0049962d4bc836a2579e035e53104adf59
Author: Rik van Riel <riel@surriel.com>
fbdev: bitblit: bound-check glyph index in bit_cursor()
This commit adds bounds checking for the glyph index in bit_cursor() to prevent
out-of-bounds reads when fetching glyphs. It addresses cases where the screen
buffer contains values larger than the current font's glyph count, which can
happen after a font resize or via malicious writes to /dev/vcsa.
Link: https://lore.kernel.org/all/6a75205c.01d0871a.3a0d52.0032.GAE@google.com/
Closes: https://syzkaller.appspot.com/bug?extid=61b1db46218109869c14
> diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c
> index 65681dcc5930d..39f44258d793f 100644
> --- a/drivers/video/fbdev/core/bitblit.c
> +++ b/drivers/video/fbdev/core/bitblit.c
> @@ -273,9 +273,14 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
> if (!vc->vc_font.data)
> return;
>
> - c = scr_readw((u16 *) vc->vc_pos);
> + c = scr_readw((u16 *) vc->vc_pos);
> attribute = get_attribute(info, c);
> - src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height));
> + c &= charmask;
> +
> + /* Clamp to font size, same as bit_putcs_aligned() */
> + if (c >= vc->vc_font.charcount)
> + c = 0;
> + src = vc->vc_font.data + (c * (w * vc->vc_font.height));
[Severity: High]
This isn't a bug introduced by this patch, but while checking the bounds for
the glyph index in bitblit.c is a great fix, could similar out-of-bounds
reads still occur in the software rotation paths?
Looking at the rotation code (fbcon_ccw.c, fbcon_cw.c, fbcon_ud.c), the bounds
checking appears to be missing entirely. For example, in fbcon_ccw.c:
drivers/video/fbdev/core/fbcon_ccw.c:ccw_cursor() {
...
c = scr_readw((u16 *) vc->vc_pos);
attribute = get_attribute(info, c);
src = par->rotated.buf + ((c & charmask) * (w * vc->vc_font.width));
...
}
And in the putcs equivalents:
drivers/video/fbdev/core/fbcon_ccw.c:ccw_putcs_aligned() {
...
src = par->rotated.buf + (scr_readw(s--) & charmask) * cellsize;
...
}
If a user loads a custom font with fewer than 256 or 512 glyphs (e.g., 100
glyphs), the rotation buffer par->rotated.buf is sized dynamically based on
charcount. If they then write an arbitrary 16-bit character index (e.g., 255)
to the screen buffer via /dev/vcsa using vcs_write(), these rotated blit
functions will mask the index with 0xff or 0x1ff and directly use it to index
par->rotated.buf.
Without clamping against vc->vc_font.charcount, wouldn't this result in
reading past the end of the heap-allocated rotation buffer?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807221956.4e9dde5c@fangorn?part=1
next prev parent reply other threads:[~2026-08-08 2:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 2:19 [PATCH] fbdev: bitblit: bound-check glyph index in bit_cursor() Rik van Riel
2026-08-08 2:46 ` sashiko-bot [this message]
2026-08-08 5:44 ` 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=20260808024649.F07761F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=riel@surriel.com \
--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