All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] fbcon: Don't drop last logo line if logo is same size as screen
@ 2026-11-20 19:16 Helge Deller
  2026-11-20 19:58 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Helge Deller @ 2026-11-20 19:16 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Henri Roosen

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.

This patch fixes this off-by-one bug, but now -as sashiko-bot noticed-
since the logo covers the whole screen there is no area left in which
the text can be scrolled. To avoid accesses outside the screen memory
simply keep the text area covering the full screen (and possibly
overwriting) the full-screen logo.

Fixes: 94e6a058b168 ("fbcon: Fix KASAN slab-out-of-bounds Read in fbcon_prepare_logo")
Tested-by: Henri Roosen <henri.roosen@ginzinger.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: stable@vger.kernel.org # v7.3+

---
v2: first sashiko-bot fixes
v3: sashiko-bot noticed another problem that screen gets cleared on full screen logo

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index d7890e119dc7..e7240eeb8381 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -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;
@@ -734,7 +734,9 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
 		pr_info("fbcon: disable boot-logo (boot-logo bigger than screen).\n");
 	} else {
 		logo_shown = FBCON_LOGO_DRAW;
-		vc->vc_top = logo_lines;
+		/* keep vc_top if logo covers whole screen */
+		if (logo_lines < vc->vc_bottom)
+			vc->vc_top = logo_lines;
 	}
 }
 #endif /* MODULE */
@@ -2269,7 +2271,9 @@ static bool fbcon_switch(struct vc_data *vc)
 
 		logo_shown = fg_console;
 		fb_show_logo(info, par->rotate);
-		update_region(vc,
+		/* avoid screen update on full screen sized logo */
+		if (vc->vc_top)
+			update_region(vc,
 			      vc->vc_origin + vc->vc_size_row * vc->vc_top,
 			      vc->vc_size_row * (vc->vc_bottom -
 						 vc->vc_top) / 2);


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] fbcon: Don't drop last logo line if logo is same size as screen
  2026-11-20 19:16 [PATCH v3] fbcon: Don't drop last logo line if logo is same size as screen Helge Deller
@ 2026-11-20 19:58 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-20 19:58 UTC (permalink / raw)
  To: Helge Deller, dri-devel

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] fbcon: slab-out-of-bounds read in fbcon_prepare_logo() when
  cols > new_cols
- [Medium] fbcon: full-screen logo overwritten in fbcon_prepare_logo()
  if rows < new_rows
- [Low] fbcon: stale vc_top kept in fbcon_prepare_logo() when dimensions
  match
--

commit d343bfc671c341be6e2717c9d73d4817c83b82d0
Author: Helge Deller <deller@kernel.org>

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

This commit allows bootlogos that match the screen height to use all rows
without dropping the last line, while keeping vc_top unchanged and skipping
update_region() when a logo covers the entire screen.

> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index 7720dfc80c165..3be7f2ade65cc 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -637,7 +637,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 r underflow vc->vc_origin and cause a slab-out-of-bounds read in
scr_readw(r) when cols > new_cols?

In fbcon_init(), vc_resize(vc, new_cols, new_rows) runs before
fbcon_prepare_logo(), reallocating vc->vc_screenbuf to new_cols * new_rows
characters and setting vc->vc_size_row = 2 * new_cols:

drivers/video/fbdev/core/fbcon.c:fbcon_prepare_logo() {
    ...
	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)
			break;
    ...
}

When transitioning from a console such as 80x25 vgacon to a narrower fbcon
(for example new_cols = 79, new_rows = 25, where vgacon_resize() returned
-EINVAL during fbcon_startup() so cols is still 80), allowing logo_lines ==
rows makes logo_lines * cols larger than rows * new_cols.  Then r = q -
logo_lines * cols starts before vc->vc_origin.

> @@ -705,7 +705,9 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
>  		pr_info("fbcon: disable boot-logo (boot-logo bigger than screen).\n");
>  	} else {
>  		logo_shown = FBCON_LOGO_DRAW;
> -		vc->vc_top = logo_lines;
> +		/* keep vc_top if logo covers whole screen */
> +		if (logo_lines < vc->vc_bottom)
> +			vc->vc_top = logo_lines;
>  	}
>  }
>  #endif /* MODULE */

[Severity: Medium]
Does a full-screen logo still set vc->vc_top to rows and get partially
overwritten whenever rows < new_rows?

Earlier in fbcon_prepare_logo(), logo_lines is clamped with min(logo_lines,
rows), whereas vc_resize() has already set vc->vc_bottom to new_rows.  When
taking over from a smaller console (such as 80x25 vgacon on a display with
more than 25 character rows), logo_lines is clamped to 25 while
vc->vc_bottom is new_rows, so logo_lines < vc->vc_bottom is true even for a
full-screen logo.  That sets vc->vc_top = rows, causing fbcon_switch() to
call update_region() after fb_show_logo() and erase the bottom new_rows -
rows lines of the logo.

[Severity: Low]
Can vc->vc_top remain non-zero when logo_lines == vc->vc_bottom if the
console dimensions did not change?

When new_cols == vc->vc_cols and new_rows == vc->vc_rows, vc_do_resize()
returns early via resize_screen() without resetting vc->vc_top to 0.  If
vc->vc_top was non-zero prior to fbcon_prepare_logo() (for example from an
earlier scrolling region or console unbind/rebind), skipping the assignment
leaves the stale non-zero vc->vc_top in place, and fbcon_switch() will call
update_region() over the full-screen logo.  Explicitly setting vc->vc_top =
0 in an else branch would avoid this.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/awCcqwVKi_n0KMhi@carbonx1?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-20 19:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 19:16 [PATCH v3] fbcon: Don't drop last logo line if logo is same size as screen Helge Deller
2026-11-20 19:58 ` sashiko-bot

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.