loader/efi/chainloader: Use shim loader image handle where available

Not reusing these handles will result in image measurements showing up
twice in the event log.

Signed-off-by: Mate Kukri <mate.kukri@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Mate Kukri authored and Daniel Kiper committed 2025-07-11 17:46:19 +02:00
1 parent e31d0cd7fb
commit 1b9a84e63b
1 file changed
+5
+5
View File
@@ -33,6 +33,7 @@
#include <grub/efi/efi.h> #include <grub/efi/efi.h>
#include <grub/efi/disk.h> #include <grub/efi/disk.h>
#include <grub/efi/memory.h> #include <grub/efi/memory.h>
#include <grub/efi/sb.h>
#include <grub/command.h> #include <grub/command.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/net.h> #include <grub/net.h>
@@ -337,6 +338,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
} }
#endif #endif
image_handle = grub_efi_get_last_verified_image_handle ();
if (image_handle == NULL)
{
status = grub_efi_load_image (0, grub_efi_image_handle, file_path, status = grub_efi_load_image (0, grub_efi_image_handle, file_path,
boot_image, size, &image_handle); boot_image, size, &image_handle);
if (status != GRUB_EFI_SUCCESS) if (status != GRUB_EFI_SUCCESS)
@@ -348,6 +352,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
goto fail; goto fail;
} }
}
/* LoadImage does not set a device handler when the image is /* LoadImage does not set a device handler when the image is
loaded from memory, so it is necessary to set it explicitly here. loaded from memory, so it is necessary to set it explicitly here.