3972172
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
3972172
From: Zhang Boyang <zhangboyang.id@gmail.com>
3972172
Date: Sun, 14 Aug 2022 15:51:54 +0800
3972172
Subject: [PATCH] kern/efi/sb: Enforce verification of font files
3972172
3972172
As a mitigation and hardening measure enforce verification of font
3972172
files. Then only trusted font files can be load. This will reduce the
3972172
attack surface at cost of losing the ability of end-users to customize
3972172
fonts if e.g. UEFI Secure Boot is enabled. Vendors can always customize
3972172
fonts because they have ability to pack fonts into their GRUB bundles.
3972172
3972172
This goal is achieved by:
3972172
3972172
  * Removing GRUB_FILE_TYPE_FONT from shim lock verifier's
3972172
    skip-verification list.
3972172
3972172
  * Adding GRUB_FILE_TYPE_FONT to lockdown verifier's defer-auth list,
3972172
    so font files must be verified by a verifier before they can be loaded.
3972172
3972172
Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
3972172
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
3972172
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3972172
(cherry picked from commit 630deb8c0d8b02b670ced4b7030414bcf17aa080)
3972172
---
3972172
 grub-core/kern/efi/sb.c   | 1 -
3972172
 grub-core/kern/lockdown.c | 1 +
3972172
 2 files changed, 1 insertion(+), 1 deletion(-)
3972172
3972172
diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c
3972172
index 89c4bb3fd1..db42c2539f 100644
3972172
--- a/grub-core/kern/efi/sb.c
3972172
+++ b/grub-core/kern/efi/sb.c
3972172
@@ -145,7 +145,6 @@ shim_lock_verifier_init (grub_file_t io __attribute__ ((unused)),
3972172
     case GRUB_FILE_TYPE_PRINT_BLOCKLIST:
3972172
     case GRUB_FILE_TYPE_TESTLOAD:
3972172
     case GRUB_FILE_TYPE_GET_SIZE:
3972172
-    case GRUB_FILE_TYPE_FONT:
3972172
     case GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY:
3972172
     case GRUB_FILE_TYPE_CAT:
3972172
     case GRUB_FILE_TYPE_HEXCAT:
3972172
diff --git a/grub-core/kern/lockdown.c b/grub-core/kern/lockdown.c
3972172
index 0bc70fd42d..af6d493cd3 100644
3972172
--- a/grub-core/kern/lockdown.c
3972172
+++ b/grub-core/kern/lockdown.c
3972172
@@ -51,6 +51,7 @@ lockdown_verifier_init (grub_file_t io __attribute__ ((unused)),
3972172
     case GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE:
3972172
     case GRUB_FILE_TYPE_ACPI_TABLE:
3972172
     case GRUB_FILE_TYPE_DEVICE_TREE_IMAGE:
3972172
+    case GRUB_FILE_TYPE_FONT:
3972172
       *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH;
3972172
 
3972172
       /* Fall through. */