Commit 2bbb54ba authored by Linus Torvalds's avatar Linus Torvalds

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
parents fbf9e3b6 2ce507f5
...@@ -292,7 +292,7 @@ static int efi_capsule_open(struct inode *inode, struct file *file) ...@@ -292,7 +292,7 @@ static int efi_capsule_open(struct inode *inode, struct file *file)
return -ENOMEM; return -ENOMEM;
} }
cap_info->phys = kzalloc(sizeof(void *), GFP_KERNEL); cap_info->phys = kzalloc(sizeof(phys_addr_t), GFP_KERNEL);
if (!cap_info->phys) { if (!cap_info->phys) {
kfree(cap_info->pages); kfree(cap_info->pages);
kfree(cap_info); kfree(cap_info);
......
...@@ -38,7 +38,7 @@ struct efivar_entry { ...@@ -38,7 +38,7 @@ struct efivar_entry {
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *, int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
struct list_head *), struct list_head *),
void *data, bool duplicates, struct list_head *head); void *data, struct list_head *head);
int efivar_entry_add(struct efivar_entry *entry, struct list_head *head); int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head); void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
......
...@@ -343,12 +343,7 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -343,12 +343,7 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
if (err) if (err)
return err; return err;
err = efivar_init(efivarfs_callback, (void *)sb, true, return efivar_init(efivarfs_callback, sb, &sfi->efivarfs_list);
&sfi->efivarfs_list);
if (err)
efivar_entry_iter(efivarfs_destroy, &sfi->efivarfs_list, NULL);
return err;
} }
static int efivarfs_get_tree(struct fs_context *fc) static int efivarfs_get_tree(struct fs_context *fc)
......
...@@ -361,7 +361,6 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid, ...@@ -361,7 +361,6 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
* efivar_init - build the initial list of EFI variables * efivar_init - build the initial list of EFI variables
* @func: callback function to invoke for every variable * @func: callback function to invoke for every variable
* @data: function-specific data to pass to @func * @data: function-specific data to pass to @func
* @duplicates: error if we encounter duplicates on @head?
* @head: initialised head of variable list * @head: initialised head of variable list
* *
* Get every EFI variable from the firmware and invoke @func. @func * 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, ...@@ -371,9 +370,9 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
*/ */
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *, int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
struct list_head *), struct list_head *),
void *data, bool duplicates, struct list_head *head) void *data, struct list_head *head)
{ {
unsigned long variable_name_size = 1024; unsigned long variable_name_size = 512;
efi_char16_t *variable_name; efi_char16_t *variable_name;
efi_status_t status; efi_status_t status;
efi_guid_t vendor_guid; efi_guid_t vendor_guid;
...@@ -390,12 +389,13 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *, ...@@ -390,12 +389,13 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
goto free; goto free;
/* /*
* Per EFI spec, the maximum storage allocated for both * A small set of old UEFI implementations reject sizes
* the variable name and variable data is 1024 bytes. * above a certain threshold, the lowest seen in the wild
* is 512.
*/ */
do { do {
variable_name_size = 1024; variable_name_size = 512;
status = efivar_get_next_variable(&variable_name_size, status = efivar_get_next_variable(&variable_name_size,
variable_name, variable_name,
...@@ -413,8 +413,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *, ...@@ -413,8 +413,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
* we'll ever see a different variable name, * we'll ever see a different variable name,
* and may end up looping here forever. * and may end up looping here forever.
*/ */
if (duplicates && if (variable_is_present(variable_name, &vendor_guid,
variable_is_present(variable_name, &vendor_guid,
head)) { head)) {
dup_variable_bug(variable_name, &vendor_guid, dup_variable_bug(variable_name, &vendor_guid,
variable_name_size); variable_name_size);
...@@ -432,9 +431,13 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *, ...@@ -432,9 +431,13 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
break; break;
case EFI_NOT_FOUND: case EFI_NOT_FOUND:
break; break;
case EFI_BUFFER_TOO_SMALL:
pr_warn("efivars: Variable name size exceeds maximum (%lu > 512)\n",
variable_name_size);
status = EFI_NOT_FOUND;
break;
default: default:
printk(KERN_WARNING "efivars: get_next_variable: status=%lx\n", pr_warn("efivars: get_next_variable: status=%lx\n", status);
status);
status = EFI_NOT_FOUND; status = EFI_NOT_FOUND;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment