[syslinux] [PATCH] Fix uninitialized variable in efi

Chris Dragan chris at chris.dragan.name
Mon Feb 5 09:04:06 PST 2018


Dear syslinux maintainers,

A colleague of mine was trying to boot Linux using UEFI built in debug
mode and the syslinux bootloader crashed for him. Upon further
investigation, my colleague determined that syslinux has a
uninitialized variable boot_free_mem when built as an EFI module. His
UEFI build was trapping any accesses to unmapped pages.

Here's a proposed patch, with description, which my colleague helped
me to come up with. Please help adopt this or another fix for this
issue.

Best Regards,
- Chris

======== SNIP ========
efi: fix uninitialized variable

In BIOS builds, bios_free_mem is initialized to address 0x413, which
contains the amount of available memory in KB.  In EFI builds this
variable has been uninitialized, leading to strange crashes with some
UEFI builds.  Initialize bios_free_mem to point to a static variable.

--- syslinux-orig/efi/main.c
+++ syslinux/efi/main.c
@@ -393,7 +393,8 @@
 void efi_init(void)
 {
        /* XXX timer */
-       *bios_free_mem = 0;
+       static uint16_t free_mem = 0;
+       bios_free_mem = &free_mem;
        syslinux_memscan_add(&efi_memscan);
        mem_init();
 }
======== SNIP ========


More information about the Syslinux mailing list