|
|
a85e8e |
From 3b6450b338cdc9f58c74f164e9bf0a7d55d6c9a5 Mon Sep 17 00:00:00 2001
|
|
|
a85e8e |
From: Andrei Borzenkov <arvidjaar@gmail.com>
|
|
|
a85e8e |
Date: Thu, 15 Dec 2016 16:07:00 +0300
|
|
|
a85e8e |
Subject: [PATCH 218/260] efi: properly terminate filepath with NULL in
|
|
|
a85e8e |
chainloader
|
|
|
a85e8e |
|
|
|
a85e8e |
EFI File Path Media Device Path is defined as NULL terminated string;
|
|
|
a85e8e |
but chainloader built file paths without final NULL. This caused error
|
|
|
a85e8e |
with Secure Boot and Linux Foundation PreLoader on Acer with InsydeH20 BIOS.
|
|
|
a85e8e |
Apparently firmware failed verification with EFI_INVALID_PARAMETER which is
|
|
|
a85e8e |
considered fatal error by PreLoader.
|
|
|
a85e8e |
|
|
|
a85e8e |
Reported and tested by Giovanni Santini <itachi.sama.amaterasu@gmail.com>
|
|
|
a85e8e |
---
|
|
|
a85e8e |
grub-core/loader/efi/chainloader.c | 6 +++++-
|
|
|
a85e8e |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
a85e8e |
|
|
|
a85e8e |
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
|
|
|
a85e8e |
index 522a716e3..adc856366 100644
|
|
|
a85e8e |
--- a/grub-core/loader/efi/chainloader.c
|
|
|
a85e8e |
+++ b/grub-core/loader/efi/chainloader.c
|
|
|
a85e8e |
@@ -122,6 +122,8 @@ copy_file_path (grub_efi_file_path_device_path_t *fp,
|
|
|
a85e8e |
if (*p == '/')
|
|
|
a85e8e |
*p = '\\';
|
|
|
a85e8e |
|
|
|
a85e8e |
+ /* File Path is NULL terminated */
|
|
|
a85e8e |
+ fp->path_name[size++] = '\0';
|
|
|
a85e8e |
fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp);
|
|
|
a85e8e |
}
|
|
|
a85e8e |
|
|
|
a85e8e |
@@ -156,8 +158,10 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename)
|
|
|
a85e8e |
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
|
|
|
a85e8e |
}
|
|
|
a85e8e |
|
|
|
a85e8e |
+ /* File Path is NULL terminated. Allocate space for 2 extra characters */
|
|
|
a85e8e |
+ /* FIXME why we split path in two components? */
|
|
|
a85e8e |
file_path = grub_malloc (size
|
|
|
a85e8e |
- + ((grub_strlen (dir_start) + 1)
|
|
|
a85e8e |
+ + ((grub_strlen (dir_start) + 2)
|
|
|
a85e8e |
* GRUB_MAX_UTF16_PER_UTF8
|
|
|
a85e8e |
* sizeof (grub_efi_char16_t))
|
|
|
a85e8e |
+ sizeof (grub_efi_file_path_device_path_t) * 2);
|
|
|
a85e8e |
--
|
|
|
a85e8e |
2.13.0
|
|
|
a85e8e |
|