Skip to contentSkip to conversation

boot: pxe_utils: Allocate space for overlay_dir before writing into it

PATCH In review Surkov Kirill 2 participants 2 messages Nov 20, 2025 – Nov 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 boot: pxe_utils: Allocate space for overlay_dir before writing into it

The pxe_utils/label_boot_extension calls snprintf on an uninitialized memory overlay_dir. This results in a crash when calling sysboot.

This commit fixes this issue.

---
 boot/pxe_utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
boot/pxe_utils.c +2 -1
index 038416203fc..fc72dbf6020 100644
@@ -463,6 +463,8 @@ static void label_boot_extension(struct pxe_context *ctx,
 	if (fdt_check_header(working_fdt))
 		return;
 
+	overlay_dir = calloc(1, len);
+
 	/* Use fdtdir for now as the overlay devicetree directory */
 	if (label->fdtdir) {
 		len = strlen(label->fdtdir);
@@ -474,7 +476,6 @@ static void label_boot_extension(struct pxe_context *ctx,
 			slash = "";
 
 		dir_len = strlen(label->fdtdir) + strlen(slash) + 1;
-		overlay_dir = calloc(1, len);
 		if (!overlay_dir)
 			return;
 
Signature · 1 line
2.43.0
#1 lore raw

Hi Surkov,

Quoted 7 lines · Surkov Kirill

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

The pxe_utils/label_boot_extension calls snprintf on an uninitialized memory overlay_dir. This results in a crash when calling sysboot.

This commit fixes this issue.

I believe we already have a patch submitted for this issue:

https://lore.kernel.org/u-boot/[email protected]/T/#u

so please give that a try and a tested-by/reviewed-by there.

Cheers,
Quentin