Skip to contentSkip to conversation

fbcon: Don't drop last logo line if logo is same size as screen

PATCH Superseded Helge Deller 2 participants 2 messages Nov 19

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Helge Deller

author maintainer
#0 lore raw

PATCH 1/1 fbcon: Don't drop last logo line if logo is same size as screen

Henri reported a regression that when a custom bootlogo is exactly as big as the screen, a white bar with the size of the font height is displayed at the bottom of the display. Fix this off-by-one bug.

Fixes 94e6a058b168 ("fbcon: Fix KASAN slab-out-of-bounds Read in fbcon_prepare_logo")
---
 drivers/video/fbdev/core/fbcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon.c +1 -1
index d7890e119dc7..2809c7a6893f 100644
@@ -666,7 +666,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
 	logo_height = fb_prepare_logo(info, par->rotate);
 	logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
 	logo_lines = min(logo_lines, rows);
-	logo_lines = min(logo_lines, new_rows - 1);
+	logo_lines = min(logo_lines, new_rows);
 	if (logo_lines <= 0) {
 		logo_lines = 0;
 		logo_shown = FBCON_LOGO_DONTSHOW;
Signature · 1 line
2.56.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] fbcon: out-of-bounds access in fbcon_prepare_logo() when logo fills screen --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] fbcon: out-of-bounds access in fbcon_prepare_logo() when logo fills screen
--

commit adce6f78babc951d216d03dcfa386a57041815ee
Author: Helge Deller <[email protected]>

fbcon: Don't drop last logo line if logo is same size as screen

This commit changes the upper bound on logo_lines in fbcon_prepare_logo() from new_rows - 1 to new_rows so that a full-screen boot logo does not have its last line clipped.

drivers/video/fbdev/core/fbcon.c static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, · line 672

Quoted 13 lines
drivers/video/fbdev/core/fbcon.c +1 -1
index d7890e119dc7d..2809c7a6893f9 100644
@@ -666,7 +666,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
 	logo_height = fb_prepare_logo(info, par->rotate);
 	logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
 	logo_lines = min(logo_lines, rows);
-	logo_lines = min(logo_lines, new_rows - 1);
+	logo_lines = min(logo_lines, new_rows);
 	if (logo_lines <= 0) {
 		logo_lines = 0;
 		logo_shown = FBCON_LOGO_DONTSHOW;

[Severity: High]
Can allowing logo_lines to equal new_rows cause an out-of-bounds read past vc->vc_screenbuf and leave the VT scrolling region empty?

When logo_lines == new_rows, it equals vc->vc_bottom (vc->vc_rows), so the end of fbcon_prepare_logo() sets vc->vc_top = vc->vc_bottom:

drivers/video/fbdev/core/fbcon.c:fbcon_prepare_logo() {
	...
	if (logo_lines > vc->vc_bottom) {
		logo_shown = FBCON_LOGO_CANSHOW;
		pr_info("fbcon: disable boot-logo (boot-logo bigger than screen).\n");
	} else {
		logo_shown = FBCON_LOGO_DRAW;
		vc->vc_top = logo_lines;
	}
}

In fbcon_switch(), the FBCON_LOGO_DRAW path then calls update_region() with start = vc->vc_origin + vc->vc_size_row * vc->vc_top (which is vc->vc_scr_end, one u16 past vc->vc_screenbuf) and count = 0. do_update_region() reads scr_readw(p) before checking whether count is zero, causing a 2-byte slab-out-of-bounds read past vc->vc_screenbuf:

drivers/tty/vt/vt.c:do_update_region() {
	...
	for(;;) {
		u16 attrib = scr_readw(p) & 0xff00;
		int startx = xx;
		u16 *q = p;
		while (xx < vc->vc_cols && count) {
	...
}

Having vc->vc_top == vc->vc_bottom == vc->vc_rows also leaves an empty scrolling region: con_scroll() returns early on top >= bottom without scrolling or resetting vc->vc_top to 0, and if DEC Origin Mode (vc->vc_decom) is enabled, gotoxy() clamps new_y < min_y to vc->state.y = vc->vc_rows, placing vc->vc_pos at or past vc->vc_scr_end for subsequent console reads and writes.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1