Skip to content

Commit 2bbb54b

Browse files
committed
Merge tag 'efi-fixes-for-v6.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI fixes from Ard Biesheuvel: "Only the EFI variable name size change is significant, and will be backported once it lands. The others are cleanup. - Fix phys_addr_t size confusion in 32-bit capsule loader - Reduce maximum EFI variable name size to 512 to work around buggy firmware - Drop some redundant code from efivarfs while at it" * tag 'efi-fixes-for-v6.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efivarfs: Drop 'duplicates' bool parameter on efivar_init() efivarfs: Drop redundant cleanup on fill_super() failure efivarfs: Request at most 512 bytes for variable names efi/capsule-loader: fix incorrect allocation size
2 parents fbf9e3b + 2ce507f commit 2bbb54b

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

drivers/firmware/efi/capsule-loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static int efi_capsule_open(struct inode *inode, struct file *file)
292292
return -ENOMEM;
293293
}
294294

295-
cap_info->phys = kzalloc(sizeof(void *), GFP_KERNEL);
295+
cap_info->phys = kzalloc(sizeof(phys_addr_t), GFP_KERNEL);
296296
if (!cap_info->phys) {
297297
kfree(cap_info->pages);
298298
kfree(cap_info);

fs/efivarfs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct efivar_entry {
3838

3939
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
4040
struct list_head *),
41-
void *data, bool duplicates, struct list_head *head);
41+
void *data, struct list_head *head);
4242

4343
int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
4444
void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);

fs/efivarfs/super.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,7 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
343343
if (err)
344344
return err;
345345

346-
err = efivar_init(efivarfs_callback, (void *)sb, true,
347-
&sfi->efivarfs_list);
348-
if (err)
349-
efivar_entry_iter(efivarfs_destroy, &sfi->efivarfs_list, NULL);
350-
351-
return err;
346+
return efivar_init(efivarfs_callback, sb, &sfi->efivarfs_list);
352347
}
353348

354349
static int efivarfs_get_tree(struct fs_context *fc)

fs/efivarfs/vars.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
361361
* efivar_init - build the initial list of EFI variables
362362
* @func: callback function to invoke for every variable
363363
* @data: function-specific data to pass to @func
364-
* @duplicates: error if we encounter duplicates on @head?
365364
* @head: initialised head of variable list
366365
*
367366
* Get every EFI variable from the firmware and invoke @func. @func
@@ -371,9 +370,9 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
371370
*/
372371
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
373372
struct list_head *),
374-
void *data, bool duplicates, struct list_head *head)
373+
void *data, struct list_head *head)
375374
{
376-
unsigned long variable_name_size = 1024;
375+
unsigned long variable_name_size = 512;
377376
efi_char16_t *variable_name;
378377
efi_status_t status;
379378
efi_guid_t vendor_guid;
@@ -390,12 +389,13 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
390389
goto free;
391390

392391
/*
393-
* Per EFI spec, the maximum storage allocated for both
394-
* the variable name and variable data is 1024 bytes.
392+
* A small set of old UEFI implementations reject sizes
393+
* above a certain threshold, the lowest seen in the wild
394+
* is 512.
395395
*/
396396

397397
do {
398-
variable_name_size = 1024;
398+
variable_name_size = 512;
399399

400400
status = efivar_get_next_variable(&variable_name_size,
401401
variable_name,
@@ -413,8 +413,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
413413
* we'll ever see a different variable name,
414414
* and may end up looping here forever.
415415
*/
416-
if (duplicates &&
417-
variable_is_present(variable_name, &vendor_guid,
416+
if (variable_is_present(variable_name, &vendor_guid,
418417
head)) {
419418
dup_variable_bug(variable_name, &vendor_guid,
420419
variable_name_size);
@@ -432,9 +431,13 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
432431
break;
433432
case EFI_NOT_FOUND:
434433
break;
434+
case EFI_BUFFER_TOO_SMALL:
435+
pr_warn("efivars: Variable name size exceeds maximum (%lu > 512)\n",
436+
variable_name_size);
437+
status = EFI_NOT_FOUND;
438+
break;
435439
default:
436-
printk(KERN_WARNING "efivars: get_next_variable: status=%lx\n",
437-
status);
440+
pr_warn("efivars: get_next_variable: status=%lx\n", status);
438441
status = EFI_NOT_FOUND;
439442
break;
440443
}

0 commit comments

Comments
 (0)