Skip to content

Commit 258dd90

Browse files
thejhardbiesheuvel
authored andcommitted
efivars: Respect "block" flag in efivar_entry_set_safe()
When the "block" flag is false, the old code would sometimes still call check_var_size(), which wrongly tells ->query_variable_store() that it can block. As far as I can tell, this can't really materialize as a bug at the moment, because ->query_variable_store only does something on X86 with generic EFI, and in that configuration we always take the efivar_entry_set_nonblocking() path. Fixes: ca0e30d ("efi: Add nonblocking option to efi_query_variable_store()") Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent dcf0c83 commit 258dd90

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/firmware/efi/vars.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
742742
{
743743
const struct efivar_operations *ops;
744744
efi_status_t status;
745+
unsigned long varsize;
745746

746747
if (!__efivars)
747748
return -EINVAL;
@@ -764,15 +765,17 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
764765
return efivar_entry_set_nonblocking(name, vendor, attributes,
765766
size, data);
766767

768+
varsize = size + ucs2_strsize(name, 1024);
767769
if (!block) {
768770
if (down_trylock(&efivars_lock))
769771
return -EBUSY;
772+
status = check_var_size_nonblocking(attributes, varsize);
770773
} else {
771774
if (down_interruptible(&efivars_lock))
772775
return -EINTR;
776+
status = check_var_size(attributes, varsize);
773777
}
774778

775-
status = check_var_size(attributes, size + ucs2_strsize(name, 1024));
776779
if (status != EFI_SUCCESS) {
777780
up(&efivars_lock);
778781
return -ENOSPC;

0 commit comments

Comments
 (0)