The caller of disk_get_part_uuid is responsible for checking the return
value, as this function returns NULL in case of an error. This was not
done, leading to a nullptr dereference on error.
We fix this by checking the return code. Further, we now issue a error
message in case the UUID cannot be determined.
Fixes: 7c90e82 ("efi: implement systemd boot loader interface")
Reported-by: Jan Kiszka <[email protected]>
Signed-off-by: Felix Moessbauer <[email protected]>
---
main.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/main.c b/main.c
index f0b9aa0..e19b1f9 100644
--- a/main.c
+++ b/main.c
@@ -189,14 +189,18 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle,
EFI_SYSTEM_TABLE *system_table)
UINT16 *boot_medium_uuidstr =
disk_get_part_uuid(loaded_image->DeviceHandle);
- bg_interface_params.loader_device_part_uuid = boot_medium_uuidstr;
- status = set_bg_interface_vars(&bg_interface_params);
- if (EFI_ERROR(status)) {
- ERROR(L"Cannot set bootloader interface variables (%r)\n",
- status);
+ if (!boot_medium_uuidstr) {
+ ERROR(L"Cannot get boot partition UUID\n");
+ } else {
+ bg_interface_params.loader_device_part_uuid =
boot_medium_uuidstr;
+ status = set_bg_interface_vars(&bg_interface_params);
+ if (EFI_ERROR(status)) {
+ ERROR(L"Cannot set bootloader interface variables
(%r)\n",
+ status);
+ }
+ INFO(L"LoaderDevicePartUUID=%s\n", boot_medium_uuidstr);
+ FreePool(boot_medium_uuidstr);
}
- INFO(L"LoaderDevicePartUUID=%s\n", boot_medium_uuidstr);
- FreePool(boot_medium_uuidstr);
FreePool(payload_dev_path);
FreePool(boot_medium_path);
--
2.49.0
--
You received this message because you are subscribed to the Google Groups "EFI
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/efibootguard-dev/20250514085307.2026263-3-felix.moessbauer%40siemens.com.