Skip to content

Commit ec4cf5d

Browse files
committed
Merge tag 'efi-fixes-for-v6.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI fixes from Ard Biesheuvel: - fixes for the EFI variable store refactor that landed in v6.0 - fixes for issues that were introduced during the merge window - back out some changes related to EFI zboot signing - we'll add a better solution for this during the next cycle * tag 'efi-fixes-for-v6.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efi: runtime: Don't assume virtual mappings are missing if VA == PA == 0 efi: libstub: Fix incorrect payload size in zboot header efi: libstub: Give efi_main() asmlinkage qualification efi: efivars: Fix variable writes without query_variable_store() efi: ssdt: Don't free memory if ACPI table was loaded successfully efi: libstub: Remove zboot signing from build options
2 parents e97eace + 37926f9 commit ec4cf5d

File tree

11 files changed

+22
-81
lines changed

11 files changed

+22
-81
lines changed

drivers/firmware/efi/Kconfig

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,6 @@ config EFI_ZBOOT
124124
is supported by the encapsulated image. (The compression algorithm
125125
used is described in the zboot image header)
126126

127-
config EFI_ZBOOT_SIGNED
128-
def_bool y
129-
depends on EFI_ZBOOT_SIGNING_CERT != ""
130-
depends on EFI_ZBOOT_SIGNING_KEY != ""
131-
132-
config EFI_ZBOOT_SIGNING
133-
bool "Sign the EFI decompressor for UEFI secure boot"
134-
depends on EFI_ZBOOT
135-
help
136-
Use the 'sbsign' command line tool (which must exist on the host
137-
path) to sign both the EFI decompressor PE/COFF image, as well as the
138-
encapsulated PE/COFF image, which is subsequently compressed and
139-
wrapped by the former image.
140-
141-
config EFI_ZBOOT_SIGNING_CERT
142-
string "Certificate to use for signing the compressed EFI boot image"
143-
depends on EFI_ZBOOT_SIGNING
144-
145-
config EFI_ZBOOT_SIGNING_KEY
146-
string "Private key to use for signing the compressed EFI boot image"
147-
depends on EFI_ZBOOT_SIGNING
148-
149127
config EFI_ARMSTUB_DTB_LOADER
150128
bool "Enable the DTB loader"
151129
depends on EFI_GENERIC_STUB && !RISCV && !LOONGARCH

drivers/firmware/efi/arm-runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static bool __init efi_virtmap_init(void)
6363

6464
if (!(md->attribute & EFI_MEMORY_RUNTIME))
6565
continue;
66-
if (md->virt_addr == 0)
66+
if (md->virt_addr == U64_MAX)
6767
return false;
6868

6969
ret = efi_create_mapping(&efi_mm, md);

drivers/firmware/efi/efi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ static __init int efivar_ssdt_load(void)
271271
acpi_status ret = acpi_load_table(data, NULL);
272272
if (ret)
273273
pr_err("failed to load table: %u\n", ret);
274+
else
275+
continue;
274276
} else {
275277
pr_err("failed to get var data: 0x%lx\n", status);
276278
}

drivers/firmware/efi/libstub/Makefile.zboot

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,11 @@ zboot-size-len-y := 4
2020
zboot-method-$(CONFIG_KERNEL_GZIP) := gzip
2121
zboot-size-len-$(CONFIG_KERNEL_GZIP) := 0
2222

23-
quiet_cmd_sbsign = SBSIGN $@
24-
cmd_sbsign = sbsign --out $@ $< \
25-
--key $(CONFIG_EFI_ZBOOT_SIGNING_KEY) \
26-
--cert $(CONFIG_EFI_ZBOOT_SIGNING_CERT)
27-
28-
$(obj)/$(EFI_ZBOOT_PAYLOAD).signed: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE
29-
$(call if_changed,sbsign)
30-
31-
ZBOOT_PAYLOAD-y := $(EFI_ZBOOT_PAYLOAD)
32-
ZBOOT_PAYLOAD-$(CONFIG_EFI_ZBOOT_SIGNED) := $(EFI_ZBOOT_PAYLOAD).signed
33-
34-
$(obj)/vmlinuz: $(obj)/$(ZBOOT_PAYLOAD-y) FORCE
23+
$(obj)/vmlinuz: $(obj)/$(EFI_ZBOOT_PAYLOAD) FORCE
3524
$(call if_changed,$(zboot-method-y))
3625

3726
OBJCOPYFLAGS_vmlinuz.o := -I binary -O $(EFI_ZBOOT_BFD_TARGET) \
38-
--rename-section .data=.gzdata,load,alloc,readonly,contents
27+
--rename-section .data=.gzdata,load,alloc,readonly,contents
3928
$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE
4029
$(call if_changed,objcopy)
4130

@@ -53,18 +42,8 @@ LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds
5342
$(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE
5443
$(call if_changed,ld)
5544

56-
ZBOOT_EFI-y := vmlinuz.efi
57-
ZBOOT_EFI-$(CONFIG_EFI_ZBOOT_SIGNED) := vmlinuz.efi.unsigned
58-
59-
OBJCOPYFLAGS_$(ZBOOT_EFI-y) := -O binary
60-
$(obj)/$(ZBOOT_EFI-y): $(obj)/vmlinuz.efi.elf FORCE
45+
OBJCOPYFLAGS_vmlinuz.efi := -O binary
46+
$(obj)/vmlinuz.efi: $(obj)/vmlinuz.efi.elf FORCE
6147
$(call if_changed,objcopy)
6248

6349
targets += zboot-header.o vmlinuz vmlinuz.o vmlinuz.efi.elf vmlinuz.efi
64-
65-
ifneq ($(CONFIG_EFI_ZBOOT_SIGNED),)
66-
$(obj)/vmlinuz.efi: $(obj)/vmlinuz.efi.unsigned FORCE
67-
$(call if_changed,sbsign)
68-
endif
69-
70-
targets += $(EFI_ZBOOT_PAYLOAD).signed vmlinuz.efi.unsigned

drivers/firmware/efi/libstub/fdt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,16 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
313313

314314
/*
315315
* Set the virtual address field of all
316-
* EFI_MEMORY_RUNTIME entries to 0. This will signal
317-
* the incoming kernel that no virtual translation has
318-
* been installed.
316+
* EFI_MEMORY_RUNTIME entries to U64_MAX. This will
317+
* signal the incoming kernel that no virtual
318+
* translation has been installed.
319319
*/
320320
for (l = 0; l < priv.boot_memmap->map_size;
321321
l += priv.boot_memmap->desc_size) {
322322
p = (void *)priv.boot_memmap->map + l;
323323

324324
if (p->attribute & EFI_MEMORY_RUNTIME)
325-
p->virt_addr = 0;
325+
p->virt_addr = U64_MAX;
326326
}
327327
}
328328
return EFI_SUCCESS;

drivers/firmware/efi/libstub/x86-stub.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,9 @@ static efi_status_t exit_boot(struct boot_params *boot_params, void *handle)
765765
* relocated by efi_relocate_kernel.
766766
* On failure, we exit to the firmware via efi_exit instead of returning.
767767
*/
768-
unsigned long efi_main(efi_handle_t handle,
769-
efi_system_table_t *sys_table_arg,
770-
struct boot_params *boot_params)
768+
asmlinkage unsigned long efi_main(efi_handle_t handle,
769+
efi_system_table_t *sys_table_arg,
770+
struct boot_params *boot_params)
771771
{
772772
unsigned long bzimage_addr = (unsigned long)startup_32;
773773
unsigned long buffer_start, buffer_end;

drivers/firmware/efi/libstub/zboot.lds

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ SECTIONS
3838
}
3939
}
4040

41-
PROVIDE(__efistub__gzdata_size = ABSOLUTE(. - __efistub__gzdata_start));
41+
PROVIDE(__efistub__gzdata_size =
42+
ABSOLUTE(__efistub__gzdata_end - __efistub__gzdata_start));
4243

4344
PROVIDE(__data_rawsize = ABSOLUTE(_edata - _etext));
4445
PROVIDE(__data_size = ABSOLUTE(_end - _etext));

drivers/firmware/efi/riscv-runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static bool __init efi_virtmap_init(void)
4141

4242
if (!(md->attribute & EFI_MEMORY_RUNTIME))
4343
continue;
44-
if (md->virt_addr == 0)
44+
if (md->virt_addr == U64_MAX)
4545
return false;
4646

4747
ret = efi_create_mapping(&efi_mm, md);

drivers/firmware/efi/vars.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/types.h>
10+
#include <linux/sizes.h>
1011
#include <linux/errno.h>
1112
#include <linux/init.h>
1213
#include <linux/module.h>
@@ -20,31 +21,30 @@ static struct efivars *__efivars;
2021

2122
static DEFINE_SEMAPHORE(efivars_lock);
2223

23-
efi_status_t check_var_size(u32 attributes, unsigned long size)
24+
static efi_status_t check_var_size(u32 attributes, unsigned long size)
2425
{
2526
const struct efivar_operations *fops;
2627

2728
fops = __efivars->ops;
2829

2930
if (!fops->query_variable_store)
30-
return EFI_UNSUPPORTED;
31+
return (size <= SZ_64K) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
3132

3233
return fops->query_variable_store(attributes, size, false);
3334
}
34-
EXPORT_SYMBOL_NS_GPL(check_var_size, EFIVAR);
3535

36+
static
3637
efi_status_t check_var_size_nonblocking(u32 attributes, unsigned long size)
3738
{
3839
const struct efivar_operations *fops;
3940

4041
fops = __efivars->ops;
4142

4243
if (!fops->query_variable_store)
43-
return EFI_UNSUPPORTED;
44+
return (size <= SZ_64K) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
4445

4546
return fops->query_variable_store(attributes, size, true);
4647
}
47-
EXPORT_SYMBOL_NS_GPL(check_var_size_nonblocking, EFIVAR);
4848

4949
/**
5050
* efivars_kobject - get the kobject for the registered efivars

fs/efivarfs/vars.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -651,22 +651,6 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
651651
if (err)
652652
return err;
653653

654-
/*
655-
* Ensure that the available space hasn't shrunk below the safe level
656-
*/
657-
status = check_var_size(attributes, *size + ucs2_strsize(name, 1024));
658-
if (status != EFI_SUCCESS) {
659-
if (status != EFI_UNSUPPORTED) {
660-
err = efi_status_to_err(status);
661-
goto out;
662-
}
663-
664-
if (*size > 65536) {
665-
err = -ENOSPC;
666-
goto out;
667-
}
668-
}
669-
670654
status = efivar_set_variable_locked(name, vendor, attributes, *size,
671655
data, false);
672656
if (status != EFI_SUCCESS) {

0 commit comments

Comments
 (0)