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