Skip to content

Commit 1b10b39

Browse files
committed
Merge tag 'efi-next-for-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI updates from Ard Biesheuvel: "Only a handful of changes this cycle, consisting of cleanup work and a low-prio bugfix: - Additional cleanup by Tim for the efivarfs variable name length confusion - Avoid freeing a bogus pointer when virtual remapping is omitted in the EFI boot stub" * tag 'efi-next-for-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efi: libstub: only free priv.runtime_map when allocated efi: Clear up misconceptions about a maximum variable name size efivarfs: Remove unused internal struct members Documentation: Mark the 'efivars' sysfs interface as removed efi: pstore: Request at most 512 bytes for variable names
2 parents 614da38 + 4b2543f commit 1b10b39

File tree

9 files changed

+33
-95
lines changed

9 files changed

+33
-95
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
What: /sys/firmware/efi/vars
2+
Date: April 2004, removed March 2023
3+
Description:
4+
This directory exposed interfaces for interacting with
5+
EFI variables. For more information on EFI variables,
6+
see 'Variable Services' in the UEFI specification
7+
(section 7.2 in specification version 2.3 Errata D).
8+
9+
The 'efivars' sysfs interface was removed in March of 2023,
10+
after being considered deprecated no later than September
11+
of 2020. Its functionality has been replaced by the
12+
'efivarfs' filesystem.

Documentation/ABI/stable/sysfs-firmware-efi-vars

-79
This file was deleted.

Documentation/filesystems/efivarfs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ accidentally.
4040
*See also:*
4141

4242
- Documentation/admin-guide/acpi/ssdt-overlays.rst
43-
- Documentation/ABI/stable/sysfs-firmware-efi-vars
43+
- Documentation/ABI/removed/sysfs-firmware-efi-vars

drivers/firmware/efi/efi-pstore.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
162162
efi_status_t status;
163163

164164
for (;;) {
165-
varname_size = 1024;
165+
/*
166+
* A small set of old UEFI implementations reject sizes
167+
* above a certain threshold, the lowest seen in the wild
168+
* is 512.
169+
*
170+
* TODO: Commonize with the iteration implementation in
171+
* fs/efivarfs to keep all the quirks in one place.
172+
*/
173+
varname_size = 512;
166174

167175
/*
168176
* If this is the first read() call in the pstore enumeration,

drivers/firmware/efi/libstub/fdt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
335335

336336
fail:
337337
efi_free(fdt_size, fdt_addr);
338-
339-
efi_bs_call(free_pool, priv.runtime_map);
338+
if (!efi_novamap)
339+
efi_bs_call(free_pool, priv.runtime_map);
340340

341341
return EFI_LOAD_ERROR;
342342
}

drivers/firmware/efi/vars.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ efi_status_t efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
215215

216216
if (data_size > 0) {
217217
status = check_var_size(nonblocking, attr,
218-
data_size + ucs2_strsize(name, 1024));
218+
data_size + ucs2_strsize(name, EFI_VAR_NAME_LEN));
219219
if (status != EFI_SUCCESS)
220220
return status;
221221
}

fs/efivarfs/internal.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ struct efivarfs_fs_info {
2424
struct efi_variable {
2525
efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)];
2626
efi_guid_t VendorGuid;
27-
unsigned long DataSize;
28-
__u8 Data[1024];
29-
efi_status_t Status;
3027
__u32 Attributes;
31-
} __attribute__((packed));
28+
};
3229

3330
struct efivar_entry {
3431
struct efi_variable var;

fs/efivarfs/vars.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor,
295295
unsigned long strsize1, strsize2;
296296
bool found = false;
297297

298-
strsize1 = ucs2_strsize(variable_name, 1024);
298+
strsize1 = ucs2_strsize(variable_name, EFI_VAR_NAME_LEN);
299299
list_for_each_entry_safe(entry, n, head, list) {
300-
strsize2 = ucs2_strsize(entry->var.VariableName, 1024);
300+
strsize2 = ucs2_strsize(entry->var.VariableName, EFI_VAR_NAME_LEN);
301301
if (strsize1 == strsize2 &&
302302
!memcmp(variable_name, &(entry->var.VariableName),
303303
strsize2) &&
@@ -396,6 +396,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
396396

397397
do {
398398
variable_name_size = 512;
399+
BUILD_BUG_ON(EFI_VAR_NAME_LEN < 512);
399400

400401
status = efivar_get_next_variable(&variable_name_size,
401402
variable_name,

include/linux/efi.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -1072,12 +1072,11 @@ static inline u64 efivar_reserved_space(void) { return 0; }
10721072
#endif
10731073

10741074
/*
1075-
* The maximum size of VariableName + Data = 1024
1076-
* Therefore, it's reasonable to save that much
1077-
* space in each part of the structure,
1078-
* and we use a page for reading/writing.
1075+
* There is no actual upper limit specified for the variable name size.
1076+
*
1077+
* This limit exists only for practical purposes, since name conversions
1078+
* are bounds-checked and name data is occasionally stored in-line.
10791079
*/
1080-
10811080
#define EFI_VAR_NAME_LEN 1024
10821081

10831082
int efivars_register(struct efivars *efivars,

0 commit comments

Comments
 (0)