Skip to content

Commit

Permalink
efi-pstore: Fix read iter after pstore API refactor
Browse files Browse the repository at this point in the history
During the internal pstore API refactoring, the EFI vars read entry was
accidentally made to update a stack variable instead of the pstore
private data pointer. This corrects the problem (and removes the now
needless argument).

Fixes: 125cc42 ("pstore: Replace arguments for read() API")
Signed-off-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
Kees Cook committed May 16, 2017
1 parent 3a7d2fd commit 6f61dd3
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions drivers/firmware/efi/efi-pstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,14 @@ static int efi_pstore_scan_sysfs_exit(struct efivar_entry *pos,
* efi_pstore_sysfs_entry_iter
*
* @record: pstore record to pass to callback
* @pos: entry to begin iterating from
*
* You MUST call efivar_enter_iter_begin() before this function, and
* efivar_entry_iter_end() afterwards.
*
* It is possible to begin iteration from an arbitrary entry within
* the list by passing @pos. @pos is updated on return to point to
* the next entry of the last one passed to efi_pstore_read_func().
* To begin iterating from the beginning of the list @pos must be %NULL.
*/
static int efi_pstore_sysfs_entry_iter(struct pstore_record *record,
struct efivar_entry **pos)
static int efi_pstore_sysfs_entry_iter(struct pstore_record *record)
{
struct efivar_entry **pos = (struct efivar_entry **)&record->psi->data;
struct efivar_entry *entry, *n;
struct list_head *head = &efivar_sysfs_list;
int size = 0;
Expand Down Expand Up @@ -218,7 +213,6 @@ static int efi_pstore_sysfs_entry_iter(struct pstore_record *record,
*/
static ssize_t efi_pstore_read(struct pstore_record *record)
{
struct efivar_entry *entry = (struct efivar_entry *)record->psi->data;
ssize_t size;

record->buf = kzalloc(EFIVARS_DATA_SIZE_MAX, GFP_KERNEL);
Expand All @@ -229,7 +223,7 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
size = -EINTR;
goto out;
}
size = efi_pstore_sysfs_entry_iter(record, &entry);
size = efi_pstore_sysfs_entry_iter(record);
efivar_entry_iter_end();

out:
Expand Down

0 comments on commit 6f61dd3

Please sign in to comment.