Skip to content

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

Closed

Description

@JinShil

Describe the bug

With auto_initramfs=0 in config.txt and fullscreen_logo_enabled=1 and fullscreen_logo_name=logo.tga in cmdline.txt, the kernel will not boot.

Steps to reproduce the behaviour

  1. Enable the fullscreen splash image as documented at https://github.com/raspberrypi/rpi-splash-screen-support
  2. Add auto_initramfs=0 to config.txt
  3. Boot. If console logging is enabled in the bootloader and kernel, you'll only see log messages from the bootloader, not the kernel. The kernel will not boot
  4. Remove fullscreen_logo_enabled=1 and fullscreen_logo_name=logo.tga from cmdline.txt. Notice it boots fine

Device (s)

Raspberry Pi CM5 Lite

System

pi@raspberrypi:~ $ cat /etc/rpi-issue
Raspberry Pi reference 2025-10-01
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 7dadcf1fc5ce1648ab09409ab978831690c9a955, stage4

pi@raspberrypi:~ $ vcgencmd version
2025/09/23 12:05:55
Copyright (c) 2012 Broadcom
version 02da46a3 (release) (embedded)

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 6.12.47+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.12.47-1+rpt1 (2025-09-16) aarch64 GNU/Linux

Logs

No response

Additional context

No response

Activity

  1. 6by9 commented on Oct 13, 2025

    @6by9
    Contributor

    The logo is loaded from /lib/firmware, so unless you have an initramfs that provides /lib/firmware then the kernel won't be able to display a logo.

    Admittedly it sounds like the error handling if it can't find the logo file has issues, but AIUI your test case is fundamentally flawed.

  2. JinShil commented on Oct 13, 2025

    @JinShil
    Author

    Admittedly it sounds like the error handling if it can't find the logo file has issues

    Yes, that's the fundamental problem I'm trying to bring attention to with this issue.

    However, why does the fullscreen splash image feature need to be dependent on initramfs? If the .tga file is in /lib/firmware, why can't it just read the file from there and display it?

  3. pelwell commented on Oct 13, 2025

    @pelwell
    Contributor

    It's probably a question of initialisation order. With a splash screen there is the desire to get it on the display as early as possible, but waiting for some USB mass storage device to enumerate in order for the rootfs to be loaded will clearly delay the presentation.

  4. 6by9 commented on Oct 13, 2025

    @6by9
    Contributor

    The logo is only loaded from the con_switch hook when fbcon initialises. If the logo isn't available at that point then it is too late.
    This is reusing the mechanism that puts up the N raspberries with a larger logo.

    I've found a couple of niggles with the handling, but actually the handling if the file isn't present seems to be reasonable.
    Fixes are in #7088

  5. 6by9 commented on Oct 21, 2025

    @6by9
    Contributor

    #7088 is now merged. That seems fairly robust to me, so please retest.

  6. 6by9 commented on Nov 19, 2025

    @6by9
    Contributor

    @JinShil Are you happy to close?

  7. JinShil commented on Nov 19, 2025

    @JinShil
    Author

    @6by9 I'm sorry, but I haven't had an opportunity to retest this, as I've had to abandon this feature due to the fact that the bootloader does not support the display resolution (800x480) and timings I need. See raspberrypi/rpi-eeprom#479 Testing this is on my todo list, but I'm under tight deadlines at the moment and can't afford the resource spend to test a feature I can't use.

    I was told by your applications team that a new bootloader would be released soon (~1 month) with the ability to specify additional timings, and I'm waiting for that to drop before I pick this up again.

  8. flyeriNsomniac commented on Sep 21, 2026

    @flyeriNsomniac

    This is still reproducible after #7088, on current rpi-6.18.y (4bb2406) and rpi-6.12.y
    (9c40c75). fb_logo.c is identical on both. Tested on a Pi 4B (8 GB) with the stock
    6.18.34+rpt-rpi-v8 kernel.

    The fullscreen path has two separate bugs (line numbers are from rpi-6.18.y):

    1. Uninitialised struct fb_image when the file can't be used. fb_set_logo_from_file() returns
      void. Every goto cleanup before line 401 (firmware not found, empty file, short header, unsupported TGA)
      leaves image->data unset, and width/height/dx/dy/depth unset too. The caller's struct fb_image image;
      (line 488) is uninitialised stack memory. It still reads image.data[0] (line 564) and calls
      fb_do_show_logo() (line 578). The two exits after line 401 ("TGA: Unexpected end of file" at 424 and the
      palette allocation failure at 459) do set image->data, but that buffer is freed at cleanup and the
      geometry is never set.
    2. Use-after-free on success. After image->data = read_logo; (line 401), execution falls through to
      cleanup: kfree(read_logo); (lines 476–477). The caller then draws from the freed buffer. It only works
      because the pages haven't been reused yet.

    Reproduction on the stock kernel with loglevel=5 fullscreen_logo=1 fullscreen_logo_name=flyer-acilis.tga
    (a 1920x1080, 24-bit, 223-colour TGA). Evidence comes from reading back the simplefb framebuffer
    (0x3e402000, a8r8g8b8) after boot and comparing it with the TGA:

    Case Setup Result
    B TGA on the root filesystem only, not in the initramfs Oops at 0.82 s, then Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b. Trace: fb_show_logo_line.constprop.0+0x1b0/0x8a0 ← fb_show_logo+0x50 ← fbcon_switch ← redraw_screen ← do_bind_con_driver ← do_take_over_console ← do_fbcon_takeover ← fbcon_fb_registered ← register_framebuffer ← simplefb_probe ← … ← simplefb_driver_init ← kernel_init. The faulting instruction 39400004 is ldrb w4, [x0], the image.data[0] load. x13 holds the ASCII tga': -2 left over from the "Failed to load logo file" message.
    A0 TGA in the initramfs Boots. Framebuffer identical to the TGA (0 of 2,073,600 pixels differ).
    A A0 + init_on_free=1 Boots. Framebuffer is completely black (all 2,073,600 pixels are 0). The file was still loaded and parsed: simplefb registration took 95 ms (91 ms in A0).

    The only difference between A0 and A is init_on_free=1. A black screen means the logo was drawn from the
    freed and zeroed read_logo.

    The patch below makes fb_set_logo_from_file() return an error, skips drawing on failure, and frees the
    image data after fb_do_show_logo(). With it applied to the same tree:

    • With init_on_free=1, the logo is drawn correctly on both simplefb and vc4drmfb (0 differing pixels).
    • With a missing file, Failed to load logo file 'yok.tga': -2 is logged for simplefb and again for vc4,
      nothing is drawn, and the system boots normally.
    --- a/drivers/video/fbdev/core/fb_logo.c
    +++ b/drivers/video/fbdev/core/fb_logo.c
    @@ -344,8 +344,8 @@
     	return false; // No duplicate found
     }
     
    -static void fb_set_logo_from_file(struct fb_info *info, const char *filepath,
    -				   struct fb_image *image, u32 *palette)
    +static int fb_set_logo_from_file(struct fb_info *info, const char *filepath,
    +				  struct fb_image *image, u32 *palette)
     {
     	int current_rows = 0, palette_index = 0, actual_row, skip_x = 0, skip_y = 0, ret;
     	unsigned char *read_logo = NULL, *header;
    @@ -473,9 +473,15 @@
     	if (image->width < info->var.xres)
     		image->dx = (info->var.xres - image->width) / 2;
     
    +	/* The caller draws image->data and frees it. */
    +	release_firmware(fw);
    +	return 0;
    +
     cleanup:
     	kfree(read_logo);
    +	image->data = NULL;
     	release_firmware(fw);
    +	return -EINVAL;
     }
     
     
    @@ -493,8 +499,9 @@
     		return 0;
     
     	if (fullscreen_logo_enabled) {
    -		fb_set_logo_from_file(info, fullscreen_logo_path,
    -			&image, palette);
    +		if (fb_set_logo_from_file(info, fullscreen_logo_path,
    +					  &image, palette))
    +			return 0;
     	} else {
     		image.depth = 8;
     		image.data = logo->data;
    @@ -576,6 +583,8 @@
     	}
     
     	fb_do_show_logo(info, &image, rotate, n);
    +	if (fullscreen_logo_enabled)
    +		kfree(image.data);
     
     	kfree(palette);
     	if (saved_pseudo_palette != NULL)

    Two more things found by reading the code (not tested, and not covered by the patch):

    • fb_set_logo_from_file() replaces info->pseudo_palette with a kzalloc()ed palette that is never
      restored or freed. The palette argument is passed by value, so the caller's kfree(palette) frees NULL.
      That leaks 1 KiB per framebuffer, and the driver's own pseudo palette stays replaced.
    • A TGA header with width or height 0 makes kmalloc_array() return ZERO_SIZE_PTR, and image.data[0]
      then faults.
  9. awss1i commented on Oct 17, 2026

    @awss1i
    Contributor

    I'll take this. I'm going to reproduce the missing file crash and the use-after-free on a bcm2711_defconfig build of rpi-6.18.y in QEMU with simplefb, then open a PR with the fix.

  10. flyeriNsomniac commented on Oct 20, 2026

    @flyeriNsomniac

    Thanks for the fix, and for catching the zero width/height case — kmalloc_array() returning ZERO_SIZE_PTR past the NULL check was not something I had spotted.

    For anyone arriving here from a downstream tree: the fix is 64dae084 in rpi-6.18.y. We had been carrying a local patch for the uninitialised fb_image and the use-after-free; we are dropping it in favour of this one, since the upstream version also covers the zero-dimension case.

    I will retest the missing-file path on a Pi 4B once we rebuild onto a tree that contains the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions