Skip to content

fbcon: Fullscreen logo loader fixes - #7686

Merged
pelwell merged 3 commits into
raspberrypi:rpi-6.18.yfrom
awss1i:fbcon-fullscreen-logo-load
Oct 18, 2026
Merged

pelwell merged 3 commits into
raspberrypi:rpi-6.18.yfrom
awss1i:fbcon-fullscreen-logo-load

Conversation

@awss1i

@awss1i awss1i commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

With the fullscreen splash enabled, a missing or unsupported logo file panics the boot, because fb_show_logo_line() draws from an uninitialised fb_image. A good file is drawn from freed memory, its palette is never restored or freed, and a logo with more than 224 colours overruns the colour table and the palette.

These commits make the loader report failure so nothing is drawn, free the image after drawing, restore the driver's palette and stop counting colours past 224.

I tested a bcm2711_defconfig kernel in QEMU with simplefb, KASAN and kmemleak, comparing the framebuffer with the TGA pixel by pixel. Missing, 0x0 and unsupported files now boot, 300 colours no longer trips KASAN, and good logos are drawn exactly, including with init_on_free=1.

@flyeriNsomniac traced the crash and the use-after-free in the issue.

Closes #7086

fb_set_logo_from_file() returns void and leaves the caller's
struct fb_image untouched when the logo file is missing or can't be
parsed. fb_show_logo_line() then reads image.data[0] and draws from
uninitialised stack memory, which oopses while the framebuffer is
registered and panics the boot. A TGA header with a width or height
of 0 does the same, because kmalloc_array() returns ZERO_SIZE_PTR,
which passes the NULL check.

When the file does load, the pixel buffer is freed before
fb_set_logo_from_file() returns, so the logo is drawn from freed
memory. With init_on_free=1 it comes out black.

Return an error from fb_set_logo_from_file() and skip drawing when
it fails, reject a zero width or height, and free the pixel buffer
once the logo has been drawn.

Fixes: 19e0758 ("Fullscreen Splash Images")
Link: raspberrypi#7086
Signed-off-by: Awss Al-Mubarak <awss@awssalmubarak.com>
Comment thread drivers/video/fbdev/core/fb_logo.c Outdated

if (fullscreen_logo_enabled) {
palette = kzalloc(256 * 4, GFP_KERNEL);
if (palette == NULL)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!palette is conventional in the kernel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to !palette.

fb_set_logo_from_file() allocates a palette for the fullscreen logo,
copies the console colours into it and installs it as
info->pseudo_palette for good. The driver's own palette is never put
back and the new one is never freed, so it leaks once the framebuffer
is unregistered, for example when simplefb is unbound. The copy also
reads 32 entries from the driver's pseudo palette, which has 16 in
simplefb.

Allocate the palette in fb_show_logo_line(), install it only while
the logo is drawn, then restore the driver's palette and free it, as
the built-in logo path already does. The logo only uses entries from
32 up, so the console colours no longer need copying.

Fixes: 19e0758 ("Fullscreen Splash Images")
Signed-off-by: Awss Al-Mubarak <awss@awssalmubarak.com>
The colour table in fb_set_logo_from_file() holds 224 colours. Past
that, new colours aren't stored, but current_rows is still
incremented for every pixel whose colour isn't in the table. Later
searches then read past the end of the table on the stack, and
fb_set_logo_RGB_palette() writes current_rows entries into a palette
that only has room for 224. KASAN reports both for a logo with 225
colours, and with 300 colours the search runs off the stack.

Only count the colours that are stored, and print the overflow
message when a colour had to be clipped. Clipped colours still map to
the first entry. The message no longer appears for a logo with
exactly 224 colours.

Fixes: 19e0758 ("Fullscreen Splash Images")
Signed-off-by: Awss Al-Mubarak <awss@awssalmubarak.com>
@awss1i
awss1i force-pushed the fbcon-fullscreen-logo-load branch from 77d3ced to 841bda7 Compare October 18, 2026 14:28
@pelwell
pelwell merged commit 5d64d1e into raspberrypi:rpi-6.18.y Oct 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto_initramfs=0 with fullscreen kernel splash image prevents the kernel from booting

3 participants