nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0319-grub-install-disable-support-for-EFI-platforms.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Jan Hlavac <jhlavac@redhat.com>
80913e
Date: Fri, 20 Nov 2020 23:51:47 +0100
80913e
Subject: [PATCH] grub-install: disable support for EFI platforms
80913e
80913e
For each platform, GRUB is shipped as a kernel image and a set of
80913e
modules. These files are then used by the grub-install utility to
80913e
install GRUB on a specific device. However, in order to support UEFI
80913e
Secure Boot, the resulting EFI binary must be signed by a recognized
80913e
private key. For this reason, for EFI platforms, most distributions also
80913e
ship prebuilt EFI binaries signed by a distribution-specific private
80913e
key. In this case, however, the grub-install utility should not be used
80913e
because it would overwrite the signed EFI binary.
80913e
80913e
The current fix is suboptimal because it preserves all EFI-related code.
80913e
A better solution could be to modularize the code and provide a
80913e
build-time option.
80913e
80913e
Resolves: rhbz#1737444
80913e
80913e
Signed-off-by: Jan Hlavac <jhlavac@redhat.com>
80913e
---
80913e
 util/grub-install.c | 35 ++++++++++++++++-------------------
80913e
 docs/grub.texi      |  7 +++++++
80913e
 util/grub-install.8 |  4 +++-
80913e
 3 files changed, 26 insertions(+), 20 deletions(-)
80913e
80913e
diff --git a/util/grub-install.c b/util/grub-install.c
b32e65
index 3bf0e063a..65bb2f99e 100644
80913e
--- a/util/grub-install.c
80913e
+++ b/util/grub-install.c
80913e
@@ -888,6 +888,22 @@ main (int argc, char *argv[])
80913e
 
80913e
   platform = grub_install_get_target (grub_install_source_directory);
80913e
 
80913e
+  switch (platform)
80913e
+    {
80913e
+    case GRUB_INSTALL_PLATFORM_ARM_EFI:
80913e
+    case GRUB_INSTALL_PLATFORM_ARM64_EFI:
80913e
+    case GRUB_INSTALL_PLATFORM_I386_EFI:
80913e
+    case GRUB_INSTALL_PLATFORM_IA64_EFI:
80913e
+    case GRUB_INSTALL_PLATFORM_X86_64_EFI:
80913e
+      is_efi = 1;
80913e
+      grub_util_error (_("this utility cannot be used for EFI platforms"
80913e
+                         " because it does not support UEFI Secure Boot"));
80913e
+      break;
80913e
+    default:
80913e
+      is_efi = 0;
80913e
+      break;
80913e
+    }
80913e
+
80913e
   {
80913e
     char *platname = grub_install_get_platform_name (platform);
80913e
     fprintf (stderr, _("Installing for %s platform.\n"), platname);
80913e
@@ -994,26 +1010,7 @@ main (int argc, char *argv[])
80913e
   grub_hostfs_init ();
80913e
   grub_host_init ();
80913e
 
80913e
-  switch (platform)
80913e
-    {
80913e
-    case GRUB_INSTALL_PLATFORM_I386_EFI:
80913e
-    case GRUB_INSTALL_PLATFORM_X86_64_EFI:
80913e
-    case GRUB_INSTALL_PLATFORM_ARM_EFI:
80913e
-    case GRUB_INSTALL_PLATFORM_ARM64_EFI:
80913e
-    case GRUB_INSTALL_PLATFORM_IA64_EFI:
80913e
-      is_efi = 1;
80913e
-      break;
80913e
-    default:
80913e
-      is_efi = 0;
80913e
-      break;
80913e
-
80913e
-      /* pacify warning.  */
80913e
-    case GRUB_INSTALL_PLATFORM_MAX:
80913e
-      break;
80913e
-    }
80913e
-
80913e
   /* Find the EFI System Partition.  */
80913e
-
80913e
   if (is_efi)
80913e
     {
80913e
       grub_fs_t fs;
80913e
diff --git a/docs/grub.texi b/docs/grub.texi
b32e65
index c54bee316..fa11cc0af 100644
80913e
--- a/docs/grub.texi
80913e
+++ b/docs/grub.texi
80913e
@@ -6185,6 +6185,13 @@ grub2-install @var{install_device}
80913e
 The device name @var{install_device} is an OS device name or a GRUB
80913e
 device name.
80913e
 
80913e
+In order to support UEFI Secure Boot, the resulting GRUB EFI binary must
80913e
+be signed by a recognized private key. For this reason, for EFI
80913e
+platforms, most distributions also ship prebuilt GRUB EFI binaries
80913e
+signed by a distribution-specific private key. In this case, however,
80913e
+@command{grub2-install} should not be used because it would overwrite
80913e
+the signed EFI binary.
80913e
+
80913e
 @command{grub2-install} accepts the following options:
80913e
 
80913e
 @table @option
80913e
diff --git a/util/grub-install.8 b/util/grub-install.8
b32e65
index 76272a39d..02371930f 100644
80913e
--- a/util/grub-install.8
80913e
+++ b/util/grub-install.8
80913e
@@ -1,4 +1,4 @@
80913e
-.TH GRUB-INSTALL 1 "Wed Feb 26 2014"
80913e
+.TH GRUB-INSTALL 1 "Fri Nov 20 2020"
80913e
 .SH NAME
80913e
 \fBgrub-install\fR \(em Install GRUB on a device.
80913e
 
80913e
@@ -31,6 +31,8 @@
80913e
 .SH DESCRIPTION
80913e
 \fBgrub-install\fR installs GRUB onto a device.  This includes copying GRUB images into the target directory (generally \fI/boot/grub\fR), and on some platforms may also include installing GRUB onto a boot sector.
80913e
 
80913e
+In order to support UEFI Secure Boot, the resulting GRUB EFI binary must be signed by a recognized private key. For this reason, for EFI platforms, most distributions also ship prebuilt GRUB EFI binaries signed by a distribution-specific private key. In this case, however, the \fBgrub-install\fR utility should not be used because it would overwrite the signed EFI binary.
80913e
+
80913e
 .SH OPTIONS
80913e
 .TP
80913e
 \fB--modules\fR=\fIMODULES\fR\!