Skip to content

Commit 58c9090

Browse files
LennySzubowiczardbiesheuvel
authored andcommitted
efi: Support for MOK variable config table
Because of system-specific EFI firmware limitations, EFI volatile variables may not be capable of holding the required contents of the Machine Owner Key (MOK) certificate store when the certificate list grows above some size. Therefore, an EFI boot loader may pass the MOK certs via a EFI configuration table created specifically for this purpose to avoid this firmware limitation. An EFI configuration table is a much more primitive mechanism compared to EFI variables and is well suited for one-way passage of static information from a pre-OS environment to the kernel. This patch adds initial kernel support to recognize, parse, and validate the EFI MOK configuration table, where named entries contain the same data that would otherwise be provided in similarly named EFI variables. Additionally, this patch creates a sysfs binary file for each EFI MOK configuration table entry found. These files are read-only to root and are provided for use by user space utilities such as mokutil. A subsequent patch will load MOK certs into the trusted platform key ring using this infrastructure. Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com> Link: https://lore.kernel.org/r/20200905013107.10457-2-lszubowi@redhat.com Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 5c4c30f commit 58c9090

File tree

7 files changed

+406
-0
lines changed

7 files changed

+406
-0
lines changed

arch/x86/kernel/setup.c

+1
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ void __init setup_arch(char **cmdline_p)
10771077
efi_fake_memmap();
10781078
efi_find_mirror();
10791079
efi_esrt_init();
1080+
efi_mokvar_table_init();
10801081

10811082
/*
10821083
* The EFI specification says that boot service code won't be

arch/x86/platform/efi/efi.c

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ static const unsigned long * const efi_tables[] = {
9191
&efi.tpm_log,
9292
&efi.tpm_final_log,
9393
&efi_rng_seed,
94+
#ifdef CONFIG_LOAD_UEFI_KEYS
95+
&efi.mokvar_table,
96+
#endif
9497
};
9598

9699
u64 efi_setup; /* efi setup_data physical address */

drivers/firmware/efi/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ obj-$(CONFIG_EFI_DEV_PATH_PARSER) += dev-path-parser.o
2828
obj-$(CONFIG_APPLE_PROPERTIES) += apple-properties.o
2929
obj-$(CONFIG_EFI_RCI2_TABLE) += rci2-table.o
3030
obj-$(CONFIG_EFI_EMBEDDED_FIRMWARE) += embedded-firmware.o
31+
obj-$(CONFIG_LOAD_UEFI_KEYS) += mokvar-table.o
3132

3233
fake_map-y += fake_mem.o
3334
fake_map-$(CONFIG_X86) += x86_fake_mem.o

drivers/firmware/efi/efi-init.c

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void __init efi_init(void)
236236

237237
reserve_regions();
238238
efi_esrt_init();
239+
efi_mokvar_table_init();
239240

240241
memblock_reserve(data.phys_map & PAGE_MASK,
241242
PAGE_ALIGN(data.size + (data.phys_map & ~PAGE_MASK)));

drivers/firmware/efi/efi.c

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ struct efi __read_mostly efi = {
4343
.esrt = EFI_INVALID_TABLE_ADDR,
4444
.tpm_log = EFI_INVALID_TABLE_ADDR,
4545
.tpm_final_log = EFI_INVALID_TABLE_ADDR,
46+
#ifdef CONFIG_LOAD_UEFI_KEYS
47+
.mokvar_table = EFI_INVALID_TABLE_ADDR,
48+
#endif
4649
};
4750
EXPORT_SYMBOL(efi);
4851

@@ -516,6 +519,9 @@ static const efi_config_table_type_t common_tables[] __initconst = {
516519
{EFI_RT_PROPERTIES_TABLE_GUID, &rt_prop, "RTPROP" },
517520
#ifdef CONFIG_EFI_RCI2_TABLE
518521
{DELLEMC_EFI_RCI2_TABLE_GUID, &rci2_table_phys },
522+
#endif
523+
#ifdef CONFIG_LOAD_UEFI_KEYS
524+
{LINUX_EFI_MOK_VARIABLE_TABLE_GUID, &efi.mokvar_table, "MOKvar" },
519525
#endif
520526
{},
521527
};

0 commit comments

Comments
 (0)