|
|
fd0330 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
fd0330 |
From: Julian Andres Klode <julian.klode@canonical.com>
|
|
|
fd0330 |
Date: Thu, 2 Dec 2021 15:03:53 +0100
|
|
|
fd0330 |
Subject: [PATCH] kern/efi/sb: Reject non-kernel files in the shim_lock
|
|
|
fd0330 |
verifier
|
|
|
fd0330 |
|
|
|
fd0330 |
We must not allow other verifiers to pass things like the GRUB modules.
|
|
|
fd0330 |
Instead of maintaining a blocklist, maintain an allowlist of things
|
|
|
fd0330 |
that we do not care about.
|
|
|
fd0330 |
|
|
|
fd0330 |
This allowlist really should be made reusable, and shared by the
|
|
|
fd0330 |
lockdown verifier, but this is the minimal patch addressing
|
|
|
fd0330 |
security concerns where the TPM verifier was able to mark modules
|
|
|
fd0330 |
as verified (or the OpenPGP verifier for that matter), when it
|
|
|
fd0330 |
should not do so on shim-powered secure boot systems.
|
|
|
fd0330 |
|
|
|
fd0330 |
Fixes: CVE-2022-28735
|
|
|
fd0330 |
|
|
|
fd0330 |
Signed-off-by: Julian Andres Klode <julian.klode@canonical.com>
|
|
|
fd0330 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
fd0330 |
(cherry picked from commit fa61ad69861c1cb3f68bf853d78fae7fd93986a0)
|
|
|
fd0330 |
---
|
|
|
fd0330 |
grub-core/kern/efi/sb.c | 39 ++++++++++++++++++++++++++++++++++++---
|
|
|
fd0330 |
include/grub/verify.h | 1 +
|
|
|
fd0330 |
2 files changed, 37 insertions(+), 3 deletions(-)
|
|
|
fd0330 |
|
|
|
fd0330 |
diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c
|
|
|
fd0330 |
index c52ec6226a..89c4bb3fd1 100644
|
|
|
fd0330 |
--- a/grub-core/kern/efi/sb.c
|
|
|
fd0330 |
+++ b/grub-core/kern/efi/sb.c
|
|
|
fd0330 |
@@ -119,10 +119,11 @@ shim_lock_verifier_init (grub_file_t io __attribute__ ((unused)),
|
|
|
fd0330 |
void **context __attribute__ ((unused)),
|
|
|
fd0330 |
enum grub_verify_flags *flags)
|
|
|
fd0330 |
{
|
|
|
fd0330 |
- *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION;
|
|
|
fd0330 |
+ *flags = GRUB_VERIFY_FLAGS_NONE;
|
|
|
fd0330 |
|
|
|
fd0330 |
switch (type & GRUB_FILE_TYPE_MASK)
|
|
|
fd0330 |
{
|
|
|
fd0330 |
+ /* Files we check. */
|
|
|
fd0330 |
case GRUB_FILE_TYPE_LINUX_KERNEL:
|
|
|
fd0330 |
case GRUB_FILE_TYPE_MULTIBOOT_KERNEL:
|
|
|
fd0330 |
case GRUB_FILE_TYPE_BSD_KERNEL:
|
|
|
fd0330 |
@@ -130,11 +131,43 @@ shim_lock_verifier_init (grub_file_t io __attribute__ ((unused)),
|
|
|
fd0330 |
case GRUB_FILE_TYPE_PLAN9_KERNEL:
|
|
|
fd0330 |
case GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE:
|
|
|
fd0330 |
*flags = GRUB_VERIFY_FLAGS_SINGLE_CHUNK;
|
|
|
fd0330 |
+ return GRUB_ERR_NONE;
|
|
|
fd0330 |
|
|
|
fd0330 |
- /* Fall through. */
|
|
|
fd0330 |
+ /* Files that do not affect secureboot state. */
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_NONE:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_LOOPBACK:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_LINUX_INITRD:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_OPENBSD_RAMDISK:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_XNU_RAMDISK:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_SIGNATURE:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_PUBLIC_KEY:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_PUBLIC_KEY_TRUST:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_PRINT_BLOCKLIST:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_TESTLOAD:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_GET_SIZE:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_FONT:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_CAT:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_HEXCAT:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_CMP:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_HASHLIST:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_TO_HASH:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_KEYBOARD_LAYOUT:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_PIXMAP:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_GRUB_MODULE_LIST:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_CONFIG:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_THEME:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_GETTEXT_CATALOG:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_FS_SEARCH:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_LOADENV:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_SAVEENV:
|
|
|
fd0330 |
+ case GRUB_FILE_TYPE_VERIFY_SIGNATURE:
|
|
|
fd0330 |
+ *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION;
|
|
|
fd0330 |
+ return GRUB_ERR_NONE;
|
|
|
fd0330 |
|
|
|
fd0330 |
+ /* Other files. */
|
|
|
fd0330 |
default:
|
|
|
fd0330 |
- return GRUB_ERR_NONE;
|
|
|
fd0330 |
+ return grub_error (GRUB_ERR_ACCESS_DENIED, N_("prohibited by secure boot policy"));
|
|
|
fd0330 |
}
|
|
|
fd0330 |
}
|
|
|
fd0330 |
|
|
|
fd0330 |
diff --git a/include/grub/verify.h b/include/grub/verify.h
|
|
|
fd0330 |
index cd129c398f..672ae16924 100644
|
|
|
fd0330 |
--- a/include/grub/verify.h
|
|
|
fd0330 |
+++ b/include/grub/verify.h
|
|
|
fd0330 |
@@ -24,6 +24,7 @@
|
|
|
fd0330 |
|
|
|
fd0330 |
enum grub_verify_flags
|
|
|
fd0330 |
{
|
|
|
fd0330 |
+ GRUB_VERIFY_FLAGS_NONE = 0,
|
|
|
fd0330 |
GRUB_VERIFY_FLAGS_SKIP_VERIFICATION = 1,
|
|
|
fd0330 |
GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2,
|
|
|
fd0330 |
/* Defer verification to another authority. */
|