|
|
fd0330 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
fd0330 |
From: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
|
|
|
fd0330 |
Date: Thu, 3 Mar 2022 13:10:56 +0100
|
|
|
fd0330 |
Subject: [PATCH] grub-core/loader/i386/efi/linux.c: do not validate kernels
|
|
|
fd0330 |
twice
|
|
|
fd0330 |
|
|
|
fd0330 |
On codebases that have shim-lock-verifier built into the grub core
|
|
|
fd0330 |
(like 2.06 upstream), shim-lock-verifier is in enforcing mode when
|
|
|
fd0330 |
booted with secureboot. It means that grub_cmd_linux() command
|
|
|
fd0330 |
attempts to perform shim validate upon opening linux kernel image,
|
|
|
fd0330 |
including kernel measurement. And the verifier correctly returns file
|
|
|
fd0330 |
open error when shim validate protocol is not present or shim fails to
|
|
|
fd0330 |
validate the kernel.
|
|
|
fd0330 |
|
|
|
fd0330 |
This makes the call to grub_linuxefi_secure_validate() redundant, but
|
|
|
fd0330 |
also harmful. As validating the kernel image twice, extends the PCRs
|
|
|
fd0330 |
with the same measurement twice. Which breaks existing sealing
|
|
|
fd0330 |
policies when upgrading from grub2.04+rhboot+sb+linuxefi to
|
|
|
fd0330 |
grub2.06+rhboot+sb+linuxefi builds. It is also incorrect to measure
|
|
|
fd0330 |
the kernel twice.
|
|
|
fd0330 |
|
|
|
fd0330 |
This patch must not be ported to older editions of grub code bases
|
|
|
fd0330 |
that do not have verifiers framework, or it is not builtin, or
|
|
|
fd0330 |
shim-lock-verifier is an optional module.
|
|
|
fd0330 |
|
|
|
fd0330 |
This patch is tested to ensure that unsigned kernels are not possible
|
|
|
fd0330 |
to boot in secureboot mode when shim rejects kernel, or shim protocol
|
|
|
fd0330 |
is missing, and that the measurements become stable once again. The
|
|
|
fd0330 |
above also ensures that CVE-2020-15705 is not reintroduced.
|
|
|
fd0330 |
|
|
|
fd0330 |
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
|
|
|
fd0330 |
---
|
|
|
fd0330 |
grub-core/loader/i386/efi/linux.c | 13 -------------
|
|
|
fd0330 |
1 file changed, 13 deletions(-)
|
|
|
fd0330 |
|
|
|
fd0330 |
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
|
|
fd0330 |
index 3cf0f9b330..941df6400b 100644
|
|
|
fd0330 |
--- a/grub-core/loader/i386/efi/linux.c
|
|
|
fd0330 |
+++ b/grub-core/loader/i386/efi/linux.c
|
|
|
fd0330 |
@@ -30,7 +30,6 @@
|
|
|
fd0330 |
#include <grub/cpu/efi/memory.h>
|
|
|
fd0330 |
#include <grub/tpm.h>
|
|
|
fd0330 |
#include <grub/safemath.h>
|
|
|
fd0330 |
-#include <grub/efi/sb.h>
|
|
|
fd0330 |
|
|
|
fd0330 |
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
fd0330 |
|
|
|
fd0330 |
@@ -278,7 +277,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|
|
fd0330 |
grub_ssize_t start, filelen;
|
|
|
fd0330 |
void *kernel = NULL;
|
|
|
fd0330 |
int setup_header_end_offset;
|
|
|
fd0330 |
- int rc;
|
|
|
fd0330 |
|
|
|
fd0330 |
grub_dl_ref (my_mod);
|
|
|
fd0330 |
|
|
|
fd0330 |
@@ -308,17 +306,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|
|
fd0330 |
goto fail;
|
|
|
fd0330 |
}
|
|
|
fd0330 |
|
|
|
fd0330 |
- if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED)
|
|
|
fd0330 |
- {
|
|
|
fd0330 |
- rc = grub_linuxefi_secure_validate (kernel, filelen);
|
|
|
fd0330 |
- if (rc <= 0)
|
|
|
fd0330 |
- {
|
|
|
fd0330 |
- grub_error (GRUB_ERR_INVALID_COMMAND,
|
|
|
fd0330 |
- N_("%s has invalid signature"), argv[0]);
|
|
|
fd0330 |
- goto fail;
|
|
|
fd0330 |
- }
|
|
|
fd0330 |
- }
|
|
|
fd0330 |
-
|
|
|
fd0330 |
lh = (struct linux_i386_kernel_header *)kernel;
|
|
|
fd0330 |
grub_dprintf ("linux", "original lh is at %p\n", kernel);
|
|
|
fd0330 |
|