nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0207-grub-core-loader-arm64-linux.c-do-not-validate-kerne.patch

b35c50
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b35c50
From: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
b35c50
Date: Fri, 4 Mar 2022 11:29:31 +0100
b35c50
Subject: [PATCH] grub-core/loader/arm64/linux.c: do not validate kernel twice
b35c50
b35c50
Call to grub_file_open(, GRUB_FILE_TYPE_LINUX_KERNEL) already passes
b35c50
the kernel file through shim-lock verifier when secureboot is on. Thus
b35c50
there is no need to validate the kernel image again. And when doing so
b35c50
again, duplicate PCR measurement is performed, breaking measurements
b35c50
compatibility with 2.04+linuxefi.
b35c50
b35c50
This patch must not be ported to older editions of grub code bases
b35c50
that do not have verifiers framework, or it is not builtin, or
b35c50
shim-lock-verifier is an optional module.
b35c50
b35c50
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
b35c50
---
b35c50
 grub-core/loader/arm64/linux.c | 13 -------------
b35c50
 1 file changed, 13 deletions(-)
b35c50
b35c50
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
b35c50
index f18d90bd74..d2af47c2c0 100644
b35c50
--- a/grub-core/loader/arm64/linux.c
b35c50
+++ b/grub-core/loader/arm64/linux.c
b35c50
@@ -34,7 +34,6 @@
b35c50
 #include <grub/i18n.h>
b35c50
 #include <grub/lib/cmdline.h>
b35c50
 #include <grub/verify.h>
b35c50
-#include <grub/efi/sb.h>
b35c50
 
b35c50
 GRUB_MOD_LICENSE ("GPLv3+");
b35c50
 
b35c50
@@ -341,7 +340,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
b35c50
   grub_off_t filelen;
b35c50
   grub_uint32_t align;
b35c50
   void *kernel = NULL;
b35c50
-  int rc;
b35c50
 
b35c50
   grub_dl_ref (my_mod);
b35c50
 
b35c50
@@ -370,17 +368,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
b35c50
       goto fail;
b35c50
     }
b35c50
 
b35c50
-  if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED)
b35c50
-    {
b35c50
-      rc = grub_linuxefi_secure_validate (kernel, filelen);
b35c50
-      if (rc <= 0)
b35c50
-	{
b35c50
-	  grub_error (GRUB_ERR_INVALID_COMMAND,
b35c50
-		      N_("%s has invalid signature"), argv[0]);
b35c50
-	  goto fail;
b35c50
-	}
b35c50
-    }
b35c50
-
b35c50
   if (grub_arch_efi_linux_check_image (kernel) != GRUB_ERR_NONE)
b35c50
     goto fail;
b35c50
   if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align) != GRUB_ERR_NONE)