nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0378-mmap-Don-t-register-cutmem-and-badram-commands-when-.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Javier Martinez Canillas <javierm@redhat.com>
80913e
Date: Wed, 14 Oct 2020 16:33:42 +0200
80913e
Subject: [PATCH] mmap: Don't register cutmem and badram commands when lockdown
80913e
 is enforced
80913e
80913e
The cutmem and badram commands can be used to remove EFI memory regions
80913e
and potentially disable the UEFI Secure Boot. Prevent the commands to be
80913e
registered if the GRUB is locked down.
80913e
80913e
Fixes: CVE-2020-27779
80913e
80913e
Reported-by: Teddy Reed <teddy.reed@gmail.com>
80913e
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
80913e
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
80913e
---
80913e
 grub-core/mmap/mmap.c | 13 +++++++------
80913e
 docs/grub.texi        |  4 ++++
80913e
 2 files changed, 11 insertions(+), 6 deletions(-)
80913e
80913e
diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c
b32e65
index 57b4e9a72..7ebf32e1e 100644
80913e
--- a/grub-core/mmap/mmap.c
80913e
+++ b/grub-core/mmap/mmap.c
80913e
@@ -20,6 +20,7 @@
80913e
 #include <grub/memory.h>
80913e
 #include <grub/machine/memory.h>
80913e
 #include <grub/err.h>
80913e
+#include <grub/lockdown.h>
80913e
 #include <grub/misc.h>
80913e
 #include <grub/mm.h>
80913e
 #include <grub/command.h>
80913e
@@ -534,12 +535,12 @@ static grub_command_t cmd, cmd_cut;
80913e
 
80913e
 GRUB_MOD_INIT(mmap)
80913e
 {
80913e
-  cmd = grub_register_command ("badram", grub_cmd_badram,
80913e
-			       N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
80913e
-			       N_("Declare memory regions as faulty (badram)."));
80913e
-  cmd_cut = grub_register_command ("cutmem", grub_cmd_cutmem,
80913e
-				   N_("FROM[K|M|G] TO[K|M|G]"),
80913e
-				   N_("Remove any memory regions in specified range."));
80913e
+  cmd = grub_register_command_lockdown ("badram", grub_cmd_badram,
80913e
+                                        N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
80913e
+                                        N_("Declare memory regions as faulty (badram)."));
80913e
+  cmd_cut = grub_register_command_lockdown ("cutmem", grub_cmd_cutmem,
80913e
+                                            N_("FROM[K|M|G] TO[K|M|G]"),
80913e
+                                            N_("Remove any memory regions in specified range."));
80913e
 
80913e
 }
80913e
 
80913e
diff --git a/docs/grub.texi b/docs/grub.texi
b32e65
index 01acf672b..f1675b614 100644
80913e
--- a/docs/grub.texi
80913e
+++ b/docs/grub.texi
80913e
@@ -4103,6 +4103,10 @@ this page is to be filtered.  This syntax makes it easy to represent patterns
80913e
 that are often result of memory damage, due to physical distribution of memory
80913e
 cells.
80913e
 
80913e
+Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
80913e
+      This prevents removing EFI memory regions to potentially subvert the
80913e
+      security mechanisms provided by the UEFI secure boot.
80913e
+
80913e
 @node blocklist
80913e
 @subsection blocklist
80913e