From a9b371c2fb3613a1d496cd46312143a96398b5de Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 7 May 2019 15:02:55 +0200 Subject: [PATCH] Make blscfg module compatible at least up to the Fedora 19 GRUB core The blscfg module isn't compatible with the GRUB core.img installed by any release older than Fedora 21. This is because the blscfg module calls to the grub_file_size() function to check if the BLS file size is correct, but the struct grub_file used as the parameter for this function changed in the GRUB version used in Fedora 21. So the function returns a wrong file size due the .size field offset being different in the older GRUB from Fedora 20 and earlier. This is causing all the BLS files to be ignored due having a wrong size and leading to GRUB menu not being populated on boot. Related: rhbz#1652806 Signed-off-by: Javier Martinez Canillas --- 0300-blscfg-remove-BLS-file-size-check.patch | 58 ++++++++++++++++++++ grub.patches | 1 + grub2.spec | 6 +- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 0300-blscfg-remove-BLS-file-size-check.patch diff --git a/0300-blscfg-remove-BLS-file-size-check.patch b/0300-blscfg-remove-BLS-file-size-check.patch new file mode 100644 index 0000000..edd6e9e --- /dev/null +++ b/0300-blscfg-remove-BLS-file-size-check.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 7 May 2019 13:54:23 +0200 +Subject: [PATCH] blscfg: remove BLS file size check + +The read_entry() function checks the BLS file size and ignores the entry +if the file size isn't correct. The problem is that it will only work if +the struct grub_file layout and fields are the same in the GRUB version +used to build the blscfg.mod, than the one that's installed as GRUB core. + +But commit 84a0e9699f8 ("Add progress module to display load progress of +files.") added a .name field to struct grub_file, and this change landed +in the GRUB version used by Fedora 21. + +Since the GRUB core is never updated when the grub2 package is upgraded, +the blscfg module won't be compatible with any GRUB that was installed by +Fedora 20 or eralier. + +The blscfg.mod is copied to /boot/grub2/i386-pc/ in legacy BIOS installs +when the GRUB configuration is switched to BLS, so this will lead to BLS +files being ignored due grub_file_size() reporting wrong file sizes. This +is caused by the struct grub_file .size field offset being different in +Fedora 20 than later releases. + +This check is doing more harm than good, so let's just remove it to make +the blscfg module compatible at least up to GRUB core that was installed +by Fedora 19. + +Related: rhbz#1652806 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index bb93b7f4904..bd008b04bec 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -412,7 +412,6 @@ static int read_entry ( + int rc = 0; + char *p = NULL; + grub_file_t f = NULL; +- grub_off_t sz; + struct bls_entry *entry; + struct read_entry_info *info = (struct read_entry_info *)data; + +@@ -442,10 +441,6 @@ static int read_entry ( + goto finish; + } + +- sz = grub_file_size (f); +- if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) +- goto finish; +- + entry = grub_zalloc (sizeof (*entry)); + if (!entry) + goto finish; diff --git a/grub.patches b/grub.patches index 845a62a..7167f04 100644 --- a/grub.patches +++ b/grub.patches @@ -297,3 +297,4 @@ Patch0296: 0296-Print-grub-emu-linux-loader-messages-as-debug.patch Patch0297: 0297-Don-t-assume-that-boot-commands-will-only-return-on-.patch Patch0298: 0298-Add-10_reset_boot_success-to-Makefile.patch Patch0299: 0299-Fix-undefined-references-for-fdt-when-building-with-.patch +Patch0300: 0300-blscfg-remove-BLS-file-size-check.patch diff --git a/grub2.spec b/grub2.spec index 62750f1..7aca3cd 100644 --- a/grub2.spec +++ b/grub2.spec @@ -7,7 +7,7 @@ Name: grub2 Epoch: 1 Version: 2.02 -Release: 81%{?dist} +Release: 82%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -518,6 +518,10 @@ rm -r /boot/grub2.tmp/ || : %endif %changelog +* Tue May 07 2019 Javier Martinez Canillas - 2.02-82 +- Make blscfg module compatible at least up to the Fedora 19 GRUB core + Related: rhbz#1652806 + * Fri May 03 2019 Neal Gompa - 2.02-81 - Add grub2-mount to grub2-tools-minimal subpackage Resolves: rhbz#1471267