提交 fadd2ce5 编写于 作者: L Linus Torvalds

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

Pull pstore fix from Kees Cook:
 "Marta noticed another misbehavior in EFI pstore, which this fixes.

  Hopefully this is the last of the v4.12 fixes for pstore!"

* tag 'pstore-v4.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  efi-pstore: Fix write/erase id tracking
...@@ -53,6 +53,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, ...@@ -53,6 +53,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
if (sscanf(name, "dump-type%u-%u-%d-%lu-%c", if (sscanf(name, "dump-type%u-%u-%d-%lu-%c",
&record->type, &part, &cnt, &time, &data_type) == 5) { &record->type, &part, &cnt, &time, &data_type) == 5) {
record->id = generic_id(time, part, cnt); record->id = generic_id(time, part, cnt);
record->part = part;
record->count = cnt; record->count = cnt;
record->time.tv_sec = time; record->time.tv_sec = time;
record->time.tv_nsec = 0; record->time.tv_nsec = 0;
...@@ -64,6 +65,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, ...@@ -64,6 +65,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
} else if (sscanf(name, "dump-type%u-%u-%d-%lu", } else if (sscanf(name, "dump-type%u-%u-%d-%lu",
&record->type, &part, &cnt, &time) == 4) { &record->type, &part, &cnt, &time) == 4) {
record->id = generic_id(time, part, cnt); record->id = generic_id(time, part, cnt);
record->part = part;
record->count = cnt; record->count = cnt;
record->time.tv_sec = time; record->time.tv_sec = time;
record->time.tv_nsec = 0; record->time.tv_nsec = 0;
...@@ -77,6 +79,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, ...@@ -77,6 +79,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
* multiple logs, remains. * multiple logs, remains.
*/ */
record->id = generic_id(time, part, 0); record->id = generic_id(time, part, 0);
record->part = part;
record->count = 0; record->count = 0;
record->time.tv_sec = time; record->time.tv_sec = time;
record->time.tv_nsec = 0; record->time.tv_nsec = 0;
...@@ -241,9 +244,15 @@ static int efi_pstore_write(struct pstore_record *record) ...@@ -241,9 +244,15 @@ static int efi_pstore_write(struct pstore_record *record)
efi_guid_t vendor = LINUX_EFI_CRASH_GUID; efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
int i, ret = 0; int i, ret = 0;
record->time.tv_sec = get_seconds();
record->time.tv_nsec = 0;
record->id = generic_id(record->time.tv_sec, record->part,
record->count);
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu-%c", snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu-%c",
record->type, record->part, record->count, record->type, record->part, record->count,
get_seconds(), record->compressed ? 'C' : 'D'); record->time.tv_sec, record->compressed ? 'C' : 'D');
for (i = 0; i < DUMP_NAME_LEN; i++) for (i = 0; i < DUMP_NAME_LEN; i++)
efi_name[i] = name[i]; efi_name[i] = name[i];
...@@ -255,7 +264,6 @@ static int efi_pstore_write(struct pstore_record *record) ...@@ -255,7 +264,6 @@ static int efi_pstore_write(struct pstore_record *record)
if (record->reason == KMSG_DUMP_OOPS) if (record->reason == KMSG_DUMP_OOPS)
efivar_run_worker(); efivar_run_worker();
record->id = record->part;
return ret; return ret;
}; };
...@@ -287,7 +295,7 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data) ...@@ -287,7 +295,7 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data)
* holding multiple logs, remains. * holding multiple logs, remains.
*/ */
snprintf(name_old, sizeof(name_old), "dump-type%u-%u-%lu", snprintf(name_old, sizeof(name_old), "dump-type%u-%u-%lu",
ed->record->type, (unsigned int)ed->record->id, ed->record->type, ed->record->part,
ed->record->time.tv_sec); ed->record->time.tv_sec);
for (i = 0; i < DUMP_NAME_LEN; i++) for (i = 0; i < DUMP_NAME_LEN; i++)
...@@ -320,10 +328,7 @@ static int efi_pstore_erase(struct pstore_record *record) ...@@ -320,10 +328,7 @@ static int efi_pstore_erase(struct pstore_record *record)
char name[DUMP_NAME_LEN]; char name[DUMP_NAME_LEN];
efi_char16_t efi_name[DUMP_NAME_LEN]; efi_char16_t efi_name[DUMP_NAME_LEN];
int found, i; int found, i;
unsigned int part;
do_div(record->id, 1000);
part = do_div(record->id, 100);
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu", snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu",
record->type, record->part, record->count, record->type, record->part, record->count,
record->time.tv_sec); record->time.tv_sec);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册