- fix bad EFI vars iterator usage

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 Comment: Kees Cook <kees@outflux.net>
 
 iQIcBAABCgAGBQJZG0rAAAoJEIly9N/cbcAmfigP/iaKLzuVid4PC3Pzf7hAwmmg
 cWrH8sPMZF6elSSKHguRWqUpyHgK6crsJYnMB8c+4+/upXMorBpX6GFK3CEZG2UO
 1vrVkJ06q0N41qNnJc3TpDV3RxecdKOs26Jtc9gm+ZMScJxZBLXBu3bfwkwE8V/c
 1RFYhFciFg2lZBwIUZb73nAtvBtMdkLACLA4isa1Gn/Q0Ah50s+MFrePNjBm2Xen
 mjhp7lP1w57X6Is3ZlbNwVEWA66qUP3PiyTasA0RiCNfQzJtT71NSCkh3849w1rX
 61cink78ZLtokdWMs510PiiUNiwivpkewftkUj33QAWkCvr7mh5rTleYNDcule3S
 GWHcq7I4HNJSf2aoAUMG6A21KGT1Rg3+EmdH6Ci1/sTOIRkitFdWTjdx/JJb6qH8
 WRmFh+lF3v5eB4pFu5z4sgqBbHFEa3cXsHqYw5rRrJuFJM/FLzVrOPTGCEfaQzj0
 Nnl53MeQ3PNK5djpJtNQ0JFkvnylgbed2E5XUQbqm5nNGWMuviBHNPKhyBroSoEZ
 LHk9EW8NRFUXZMjPEbi+2vPigz4/UAXBcc/MOPqdbZCBughTdq7xicIdil31hPxn
 WeJzhXGs0rVEdzZJaUDYT+yKuTbTBeYwl/ujAGtqSB45lk/VLdZ0vWRz7PL83MwL
 BwOer++6MGmiO0JnkS85
 =bdBo
 -----END PGP SIGNATURE-----

Merge tag 'pstore-v4.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull pstore fix from Kees Cook:
 "Fix bad EFI vars iterator usage"

* tag 'pstore-v4.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  efi-pstore: Fix read iter after pstore API refactor
This commit is contained in:
Linus Torvalds 2017-05-16 13:29:07 -07:00
commit b23afd3848

View File

@ -155,19 +155,14 @@ static int efi_pstore_scan_sysfs_exit(struct efivar_entry *pos,
* efi_pstore_sysfs_entry_iter * efi_pstore_sysfs_entry_iter
* *
* @record: pstore record to pass to callback * @record: pstore record to pass to callback
* @pos: entry to begin iterating from
* *
* You MUST call efivar_enter_iter_begin() before this function, and * You MUST call efivar_enter_iter_begin() before this function, and
* efivar_entry_iter_end() afterwards. * 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, static int efi_pstore_sysfs_entry_iter(struct pstore_record *record)
struct efivar_entry **pos)
{ {
struct efivar_entry **pos = (struct efivar_entry **)&record->psi->data;
struct efivar_entry *entry, *n; struct efivar_entry *entry, *n;
struct list_head *head = &efivar_sysfs_list; struct list_head *head = &efivar_sysfs_list;
int size = 0; int size = 0;
@ -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) static ssize_t efi_pstore_read(struct pstore_record *record)
{ {
struct efivar_entry *entry = (struct efivar_entry *)record->psi->data;
ssize_t size; ssize_t size;
record->buf = kzalloc(EFIVARS_DATA_SIZE_MAX, GFP_KERNEL); record->buf = kzalloc(EFIVARS_DATA_SIZE_MAX, GFP_KERNEL);
@ -229,7 +223,7 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
size = -EINTR; size = -EINTR;
goto out; goto out;
} }
size = efi_pstore_sysfs_entry_iter(record, &entry); size = efi_pstore_sysfs_entry_iter(record);
efivar_entry_iter_end(); efivar_entry_iter_end();
out: out: