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