More EFI fixes for v5.17:

- don't treat valid hartid U32_MAX as a failure return code (RISC-V)
 - avoid blocking query_variable_info() call when blocking is not allowed
 -----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEE+9lifEBpyUIVN1cpw08iOZLZjyQFAmIckWkACgkQw08iOZLZ
 jyQ3Swv+OrokwynUcqlcOtK5ROVdccezBZV9K+qkNOX0Kk45My5u2aKg6TsftbKV
 /f90jSeXphRkv+A4MjP6jS9nHB23sfabY8DMO7ILQnZSZYlWveUUgJSfdernifLK
 oDWuHwlgGIMfE/Evg9HK7zk080Hrne0qrL/48jrP1VG4xNMSMGZB9E1rxsP566cI
 OPSBNQF76Zm7GO2Jf8iFor2ajBqG8n0tCANJQQvQ7FHcoEDtEJQvUTYUU7C4/zcY
 HMe0r6xs7n8+QjwA1L7hJelYmhdwcfdYHzm2XTwFglPFEceUgmBzAzY3vQv/pPBF
 2N0sWAbcHNz+afwzu5yh9gUfYLklV5sIxGsNhd/EEy3YyBZUoTW+pUz/bW0HzItO
 TOSWHgyUhnRHJyMF1Kr14/Vn1nZ5UCl15KWK8IpPybc6Prz1KDbPCC7mT73nu1Qh
 8DycSay1vicj9FW2SJgA+kqP79oIh1FZPXEZgvPQPKX58YeWdJaWJ5dFMRiuEYAJ
 pa345FRy
 =GAs/
 -----END PGP SIGNATURE-----

Merge tag 'efi-urgent-for-v5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

Pull EFI fixes from Ard Biesheuvel:

 - don't treat valid hartid U32_MAX as a failure return code (RISC-V)

 - avoid blocking query_variable_info() call when blocking is not
   allowed

* tag 'efi-urgent-for-v5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
  efivars: Respect "block" flag in efivar_entry_set_safe()
  riscv/efi_stub: Fix get_boot_hartid_from_fdt() return value
This commit is contained in:
Linus Torvalds 2022-02-28 12:44:33 -08:00
commit 201b5c016f
2 changed files with 14 additions and 8 deletions

View file

@ -25,7 +25,7 @@ typedef void __noreturn (*jump_kernel_func)(unsigned int, unsigned long);
static u32 hartid;
static u32 get_boot_hartid_from_fdt(void)
static int get_boot_hartid_from_fdt(void)
{
const void *fdt;
int chosen_node, len;
@ -33,23 +33,26 @@ static u32 get_boot_hartid_from_fdt(void)
fdt = get_efi_config_table(DEVICE_TREE_GUID);
if (!fdt)
return U32_MAX;
return -EINVAL;
chosen_node = fdt_path_offset(fdt, "/chosen");
if (chosen_node < 0)
return U32_MAX;
return -EINVAL;
prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len);
if (!prop || len != sizeof(u32))
return U32_MAX;
return -EINVAL;
return fdt32_to_cpu(*prop);
hartid = fdt32_to_cpu(*prop);
return 0;
}
efi_status_t check_platform_features(void)
{
hartid = get_boot_hartid_from_fdt();
if (hartid == U32_MAX) {
int ret;
ret = get_boot_hartid_from_fdt();
if (ret) {
efi_err("/chosen/boot-hartid missing or invalid!\n");
return EFI_UNSUPPORTED;
}

View file

@ -742,6 +742,7 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
{
const struct efivar_operations *ops;
efi_status_t status;
unsigned long varsize;
if (!__efivars)
return -EINVAL;
@ -764,15 +765,17 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
return efivar_entry_set_nonblocking(name, vendor, attributes,
size, data);
varsize = size + ucs2_strsize(name, 1024);
if (!block) {
if (down_trylock(&efivars_lock))
return -EBUSY;
status = check_var_size_nonblocking(attributes, varsize);
} else {
if (down_interruptible(&efivars_lock))
return -EINTR;
status = check_var_size(attributes, varsize);
}
status = check_var_size(attributes, size + ucs2_strsize(name, 1024));
if (status != EFI_SUCCESS) {
up(&efivars_lock);
return -ENOSPC;