From: Stefan Berger <stefanb@linux.ibm.com> Date: 2021-03-09 03:21:04
This series of patches fixes a couple of issues related to TPM2
event logs, such as the disappearance of the TPM2 log on QEMU machines
running with UEFI (my fault) and a kernel fault due to an integer under-
flow when reading the TPM 2 log multiple times.
Regards,
Stefan
Stefan Berger (3):
tpm: efi: Use local variable for calculating final log size
tpm: acpi: Check eventlog signature before using it
tpm: vtpm_proxy: Avoid reading host log when using a virtual device
drivers/char/tpm/eventlog/acpi.c | 31 +++++++++++++++++++++++++++++-
drivers/char/tpm/eventlog/common.c | 3 +++
drivers/char/tpm/eventlog/efi.c | 10 ++++++----
3 files changed, 39 insertions(+), 5 deletions(-)
--
2.29.2
From: Stefan Berger <stefanb@linux.ibm.com> Date: 2021-03-09 03:21:05
Check the eventlog signature before using it. This avoids using an
empty log, as may be the case when QEMU created the ACPI tables,
rather than probing the EFI log next. This resolves an issue where
the EFI log was empty since an empty ACPI log was used.
Fixes: 85467f63a05c ("tpm: Add support for event log pointer found in TPM2 ACPI table")
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
drivers/char/tpm/eventlog/acpi.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
@@ -41,6 +41,25 @@ struct acpi_tcpa {};};+/* check that the given log is indeed a TPM2 log */+staticinttpm_check_tpm2_log_header(void*bios_event_log,u64len)+{+structtcg_efi_specid_event_head*efispecid;+structtcg_pcr_event*event_header=bios_event_log;++if(len<sizeof(*event_header))+return1;+len-=sizeof(*event_header);++efispecid=(structtcg_efi_specid_event_head*)event_header->event;+if(len<sizeof(*efispecid)||+memcmp(efispecid->signature,TCG_SPECID_SIG,+sizeof(TCG_SPECID_SIG)))+return1;++return0;+}+/* read binary bios log */inttpm_read_log_acpi(structtpm_chip*chip){
@@ -52,6 +71,7 @@ int tpm_read_log_acpi(struct tpm_chip *chip)structacpi_table_tpm2*tbl;structacpi_tpm2_phy*tpm2_phy;intformat;+intret;log=&chip->log;
@@ -112,6 +132,7 @@ int tpm_read_log_acpi(struct tpm_chip *chip)log->bios_event_log_end=log->bios_event_log+len;+ret=-EIO;virt=acpi_os_map_iomem(start,len);if(!virt)gotoerr;
@@ -119,11 +140,19 @@ int tpm_read_log_acpi(struct tpm_chip *chip)memcpy_fromio(log->bios_event_log,virt,len);acpi_os_unmap_iomem(virt,len);++if(chip->flags&TPM_CHIP_FLAG_TPM2&&+tpm_check_tpm2_log_header(log->bios_event_log,len)){+/* try EFI log next */+ret=-ENODEV;+gotoerr;+}+returnformat;err:kfree(log->bios_event_log);log->bios_event_log=NULL;-return-EIO;+returnret;}
From: Stefan Berger <stefanb@linux.ibm.com> Date: 2021-03-09 03:21:05
Avoid allocating memory and reading the host log when a virtual device
is used since this log is of no use to that driver. A virtual
device can be identified through the flag TPM_CHIP_FLAG_VIRTUAL, which
is only set for the tpm_vtpm_proxy driver.
Fixes: 6f99612e2500 ("tpm: Proxy driver for supporting multiple emulated TPMs")
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
drivers/char/tpm/eventlog/common.c | 3 +++
1 file changed, 3 insertions(+)
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-03-10 19:52:47
On Mon, Mar 08, 2021 at 10:19:53PM -0500, Stefan Berger wrote:
quoted hunk
Check the eventlog signature before using it. This avoids using an
empty log, as may be the case when QEMU created the ACPI tables,
rather than probing the EFI log next. This resolves an issue where
the EFI log was empty since an empty ACPI log was used.
Fixes: 85467f63a05c ("tpm: Add support for event log pointer found in TPM2 ACPI table")
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
drivers/char/tpm/eventlog/acpi.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)