diff --git a/0006-efi-properly-terminate-filepath-with-NULL-in-chainloader.patch b/0006-efi-properly-terminate-filepath-with-NULL-in-chainloader.patch new file mode 100644 index 0000000..b796107 --- /dev/null +++ b/0006-efi-properly-terminate-filepath-with-NULL-in-chainloader.patch @@ -0,0 +1,44 @@ +From ce95549cc54b5d6f494608a7c390dba3aab4fba7 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Thu, 15 Dec 2016 16:07:00 +0300 +Subject: efi: properly terminate filepath with NULL in chainloader + +EFI File Path Media Device Path is defined as NULL terminated string; +but chainloader built file paths without final NULL. This caused error +with Secure Boot and Linux Foundation PreLoader on Acer with InsydeH20 BIOS. +Apparently firmware failed verification with EFI_INVALID_PARAMETER which is +considered fatal error by PreLoader. + +Reported and tested by Giovanni Santini +--- + grub-core/loader/efi/chainloader.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 522a716..adc8563 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -122,6 +122,8 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, + if (*p == '/') + *p = '\\'; + ++ /* File Path is NULL terminated */ ++ fp->path_name[size++] = '\0'; + fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp); + } + +@@ -156,8 +158,10 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) + d = GRUB_EFI_NEXT_DEVICE_PATH (d); + } + ++ /* File Path is NULL terminated. Allocate space for 2 extra characters */ ++ /* FIXME why we split path in two components? */ + file_path = grub_malloc (size +- + ((grub_strlen (dir_start) + 1) ++ + ((grub_strlen (dir_start) + 2) + * GRUB_MAX_UTF16_PER_UTF8 + * sizeof (grub_efi_char16_t)) + + sizeof (grub_efi_file_path_device_path_t) * 2); +-- +cgit v1.0 + diff --git a/PKGBUILD b/PKGBUILD index a090ce3..86e2fb6 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -23,7 +23,7 @@ _UNIFONT_VER="6.3.20131217" pkgname="grub" pkgdesc="GNU GRand Unified Bootloader (2)" pkgver=2.02.beta3 -pkgrel=4 +pkgrel=5 epoch=1 url="https://www.gnu.org/software/grub/" arch=('x86_64' 'i686') @@ -64,6 +64,7 @@ source=("grub-${_pkgver}::git+git://git.sv.gnu.org/grub.git#tag=${_GRUB_GIT_TAG} '0003-10_linux-detect-archlinux-initramfs.patch' '0004-add-GRUB_COLOR_variables.patch' '0005-10_linux-fix-grouping-of-tests.patch' + '0006-efi-properly-terminate-filepath-with-NULL-in-chainloader.patch' 'grub.default' 'grub.cfg') @@ -76,6 +77,7 @@ sha256sums=('SKIP' 'b41e4438319136b5e74e0abdfcb64ae115393e4e15207490272c425f54026dd3' 'a5198267ceb04dceb6d2ea7800281a42b3f91fd02da55d2cc9ea20d47273ca29' 'bf712de689a944ac23a0303bbcc223eedf8d4fcb5c94bdc071c71c2444158a7f' + 'd99f47642d325398873346e25ecb646c387e358e25b05128fa333cc7721a7388' 'df764fbd876947dea973017f95371e53833bf878458140b09f0b70d900235676' 'c5e4f3836130c6885e9273c21f057263eba53f4b7c0e2f111f6e5f2e487a47ad') @@ -109,6 +111,10 @@ prepare() { patch -Np1 -i "${srcdir}/0005-10_linux-fix-grouping-of-tests.patch" echo + msg "Patch to properly terminate filepath with NULL in chainloader" + patch -Np1 -i "${srcdir}/0006-efi-properly-terminate-filepath-with-NULL-in-chainloader.patch" + echo + msg "Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme" sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "${srcdir}/grub-${_pkgver}/configure.ac"