Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f7de85a authored by Seiji Aguchi's avatar Seiji Aguchi Committed by Tony Luck
Browse files

efi_pstore: Add a format check for an existing variable name at reading time



[Issue]

a format of variable name has been updated to type, id, count and ctime
to support holding multiple logs.

Format of current variable name
  dump-type0-1-2-12345678

  type:0
  id:1
  count:2
  ctime:12345678

On the other hand, if an old variable name before being updated
remains, users can't read it via /dev/pstore.

Format of old variable name
  dump-type0-1-12345678

  type:0
  id:1
  ctime:12345678

[Solution]

This patch add a format check for the old variable name in a read callback
to make it readable.

Signed-off-by: default avatarSeiji Aguchi <seiji.aguchi@hds.com>
Acked-by: default avatarMike Waychison <mikew@google.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 755d4fe4
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -681,6 +681,24 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
				*count = cnt;
				timespec->tv_sec = time;
				timespec->tv_nsec = 0;
			} else if (sscanf(name, "dump-type%u-%u-%lu",
				   type, &part, &time) == 3) {
				/*
				 * Check if an old format,
				 * which doesn't support holding
				 * multiple logs, remains.
				 */
				*id = part;
				*count = 0;
				timespec->tv_sec = time;
				timespec->tv_nsec = 0;
			} else {
				efivars->walk_entry = list_entry(
						efivars->walk_entry->list.next,
						struct efivar_entry, list);
				continue;
			}

			get_var_data_locked(efivars, &efivars->walk_entry->var);
			size = efivars->walk_entry->var.DataSize;
			*buf = kmalloc(size, GFP_KERNEL);
@@ -688,11 +706,11 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
				return -ENOMEM;
			memcpy(*buf, efivars->walk_entry->var.Data,
			       size);
				efivars->walk_entry = list_entry(efivars->walk_entry->list.next,
			efivars->walk_entry = list_entry(
					efivars->walk_entry->list.next,
					struct efivar_entry, list);
			return size;
		}
		}
		efivars->walk_entry = list_entry(efivars->walk_entry->list.next,
						 struct efivar_entry, list);
	}