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 3/9]: Replace scr_readw/writew by scr_readg/writeg, etc
Date: Thu, 27 Aug 2026 19:18:16 +0000 [thread overview]
Message-ID: <20260827191816.8459F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <apCGKUotSUZLvngV@MAC.fritz.box>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The loop evaluating screen blankness in fbcon_prepare_logo increments the pointer incorrectly, leading to overlapping/unaligned 32-bit glyph reads and an out-of-bounds read.
- [High] Incorrect pointer arithmetic in fbcon_switch when scrolling the logo leads to severe screen buffer corruption in 32-bit glyph mode.
--
commit 161dfd956a8c1063b40c6d0ff761c9b6540eff43
Author: Alan Mackenzie <acm@muc.de>
Replace scr_readw/writew by scr_readg/writeg, etc
This patch updates vt and fbcon drivers to handle 32-bit glyphs by
replacing 16-bit specific scr_readw/writew with scr_readg/writeg,
adjusting pointers and attributes accordingly.
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
[ ... ]
> @@ -663,8 +663,8 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
> q = (unsigned short *) (vc->vc_origin +
> vc->vc_size_row * rows);
> step = logo_lines * cols;
> - for (r = q - logo_lines * cols; r < q; r++)
> - if (scr_readw(r) != vc->vc_video_erase_char)
> + for (r = q - logo_lines * cols * GLYPH_HW; r < q; r++)
> + if (scr_readg(r) != vc->vc_video_erase_char)
[Severity: High]
Could this loop read out of bounds when evaluating screen blankness?
The pointer r is of type unsigned short *, so r++ advances it by 2 bytes.
However, scr_readg() reads 4 bytes, resulting in overlapping reads. On the
final iteration (when r equals q - 1), it appears scr_readg() would read 2
bytes past the end of the screen buffer allocation. Should this increment by
GLYPH_HW instead?
> break;
> if (r != q && new_rows >= rows + logo_lines) {
> save = kmalloc(array3_size(logo_lines, new_cols, GLYPH_SZ),
[ ... ]
> @@ -2161,8 +2165,23 @@ static bool fbcon_switch(struct vc_data *vc)
> struct vc_data *conp2 = vc_cons[logo_shown].d;
>
> if (conp2->vc_top == logo_lines
> - && conp2->vc_bottom == conp2->vc_rows)
> + && conp2->vc_bottom == conp2->vc_rows) {
> + /* Scroll the bottom part of the screen up to fill the
> + * logo lines.
> + */
> + i = conp2->vc_bottom - conp2->vc_top;
> + d = (unsigned short *)conp2->vc_origin;
> + s = (unsigned short *)(conp2->vc_origin +
> + logo_lines * conp2->vc_size_row);
> + while (i--) {
> + scr_memcpyw(d, s, conp2->vc_size_row);
> + d += conp2->vc_cols;
> + s += conp2->vc_cols;
[Severity: High]
Does this pointer arithmetic corrupt the console screen buffer for 32-bit
glyphs? The pointers d and s are unsigned short *, so advancing them by
vc_cols moves them forward by vc_cols * 2 bytes. Since conp2->vc_size_row
is vc_cols * 4 bytes for 32-bit glyphs, this seems to advance the pointers
by exactly half a row.
Because of this, the next loop iteration would overwrite the middle of the
previously copied row. Furthermore, the subsequent scr_memset_worl() would
start clearing from the wrong offset. Should these pointers be advanced by
conp2->vc_cols * GLYPH_HW?
> + }
> + scr_memset_worl(d, conp2->vc_video_erase_char,
> + conp2->vc_size_row * logo_lines);
> conp2->vc_top = 0;
> + }
> logo_shown = FBCON_LOGO_CANSHOW;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/apCEDM2sWv_M354-@MAC.fritz.box?part=3
next prev parent reply other threads:[~2026-08-27 19:18 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 [this message]
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
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=20260827191816.8459F1F000E9@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 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.