Commit fe7eb023 authored by Matthew Garrett's avatar Matthew Garrett Committed by Jarkko Sakkinen

tpm: Append the final event log to the TPM event log

Any events that are logged after GetEventsLog() is called are logged to
the EFI Final Events table. These events are defined as being in the
crypto agile log format, so we can just append them directly to the
existing log if it's in the same format. In theory we can also construct
old-style SHA1 log entries for devices that only return logs in that
format, but EDK2 doesn't generate the final event log in that case so
it doesn't seem worth it at the moment.
Signed-off-by: default avatarMatthew Garrett <mjg59@google.com>
Reviewed-by: default avatarBartosz Szczepanek <bsz@semihalf.com>
Tested-by: default avatarBartosz Szczepanek <bsz@semihalf.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent c46f3405
......@@ -16,10 +16,13 @@
int tpm_read_log_efi(struct tpm_chip *chip)
{
struct efi_tcg2_final_events_table *final_tbl = NULL;
struct linux_efi_tpm_eventlog *log_tbl;
struct tpm_bios_log *log;
u32 log_size;
u8 tpm_log_version;
void *tmp;
int ret;
if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
return -ENODEV;
......@@ -47,15 +50,48 @@ int tpm_read_log_efi(struct tpm_chip *chip)
/* malloc EventLog space */
log->bios_event_log = kmemdup(log_tbl->log, log_size, GFP_KERNEL);
if (!log->bios_event_log)
goto err_memunmap;
log->bios_event_log_end = log->bios_event_log + log_size;
if (!log->bios_event_log) {
ret = -ENOMEM;
goto out;
}
log->bios_event_log_end = log->bios_event_log + log_size;
tpm_log_version = log_tbl->version;
memunmap(log_tbl);
return tpm_log_version;
err_memunmap:
ret = tpm_log_version;
if (efi.tpm_final_log == EFI_INVALID_TABLE_ADDR ||
efi_tpm_final_log_size == 0 ||
tpm_log_version != EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)
goto out;
final_tbl = memremap(efi.tpm_final_log,
sizeof(*final_tbl) + efi_tpm_final_log_size,
MEMREMAP_WB);
if (!final_tbl) {
pr_err("Could not map UEFI TPM final log\n");
kfree(log->bios_event_log);
ret = -ENOMEM;
goto out;
}
tmp = krealloc(log->bios_event_log,
log_size + efi_tpm_final_log_size,
GFP_KERNEL);
if (!tmp) {
kfree(log->bios_event_log);
ret = -ENOMEM;
goto out;
}
log->bios_event_log = tmp;
memcpy((void *)log->bios_event_log + log_size,
final_tbl->events, efi_tpm_final_log_size);
log->bios_event_log_end = log->bios_event_log +
log_size + efi_tpm_final_log_size;
out:
memunmap(final_tbl);
memunmap(log_tbl);
return -ENOMEM;
return ret;
}
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