qfw: Fix segfault from uninitialized variables in sandbox
PATCH 1/1 qfw: Fix segfault from uninitialized variables in sandbox
From: "Kory Maincent (TI.com)" <[email protected]>
There are cases where qfw_read_entry() does not set the output parameter passed by address. This occurs with qfw_sandbox_read_entry_dma, which leaves the size variables uninitialized and causes a segfault when running bootflow scan in U-Boot sandbox.
$ ./u-boot
...
U-Boot 2026.01-rc1-00199-gc2637036b8f0 (Nov 04 2025 - 10:32:21 +0100)
...
Hit any key to stop autoboot: 0
=> bootflow scan
efi_var_to_file() Cannot persist EFI variables without system partition
efi_tcg2_register() Missing TPMv2 device for EFI_TCG_PROTOCOL
efi_rng_register() Missing RNG device for EFI_RNG_PROTOCOL
scanning bus for devices...
[3] 1015761 segmentation fault (core dumped) ./u-bootInitalize all these variables to 0 to fix this issue.
--- common/qfw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/qfw.c +1 -1
@@ -109,7 +109,7 @@ int qemu_fwcfg_setup_kernel(struct udevice *qfw_dev, ulong load_addr, ulong initrd_addr) {char *data_addr; -u32 setup_size, kernel_size, cmdline_size, initrd_size; +u32 setup_size =0 , kernel_size =0 , cmdline_size =0 , initrd_size =0 ;qfw_read_entry (qfw_dev,FW_CFG_SETUP_SIZE ,4 , &setup_size);qfw_read_entry (qfw_dev,FW_CFG_KERNEL_SIZE ,4 , &kernel_size);
Signature · 1 line
2.43.0
Quoted 17 lines · Kory Maincent
There are cases where
qfw_read_entry()does not set the output parameter passed by address. This occurs withqfw_sandbox_read_entry_dma, which leaves the size variables uninitialized and causes a segfault when running bootflow scan in U-Boot sandbox.$ ./u-boot ... U-Boot 2026.01-rc1-00199-gc2637036b8f0 (Nov 04 2025 - 10:32:21 +0100) ... Hit any key to stop autoboot: 0 => bootflow scan efi_var_to_file() Cannot persist EFI variables without system partition efi_tcg2_register() Missing TPMv2 device for EFI_TCG_PROTOCOL efi_rng_register() Missing RNG device for EFI_RNG_PROTOCOL scanning bus for devices... [3] 1015761 segmentation fault (core dumped) ./u-boot
Quoted 1 line
[...]
Applied to u-boot/master, thanks!
[1/1] qfw: Fix segfault from uninitialized variables in sandbox
commit: 664cdc5fd524db0c09c1200e89e65207a3b772a4
Signature · 1 line
Tom