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 <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-05-07 15:02:55 +02:00
parent e95ccc7ba6
commit f52f8fe0ab
No known key found for this signature in database
GPG key ID: C751E590D63F3D69
3 changed files with 64 additions and 1 deletions

View file

@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
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 <javierm@redhat.com>
---
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;

View file

@ -289,3 +289,4 @@ Patch0288: 0288-10_linux_bls-don-t-add-users-option-to-generated-men.patch
Patch0289: 0289-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch
Patch0290: 0290-HTTP-boot-strncmp-returns-0-on-equal.patch
Patch0291: 0291-Add-10_reset_boot_success-to-Makefile.patch
Patch0292: 0292-blscfg-remove-BLS-file-size-check.patch

View file

@ -7,7 +7,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 78%{?dist}
Release: 79%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -476,6 +476,10 @@ rm -r /boot/grub2.tmp/ || :
%endif
%changelog
* Tue May 07 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-79
- Make blscfg module compatible at least up to the Fedora 19 GRUB core
Related: rhbz#1652806
* Thu Apr 18 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-78
- Add 10_reset_boot_success to Makefile
Related: rhbz#1701003