From: Morten Linderud <morten@linderud.pw>
To: Peter Huewe <peterhuewe@gmx.de>,
Jarkko Sakkinen <jarkko@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>
Cc: Morten Linderud <morten@linderud.pw>,
Stefan Berger <stefanb@linux.ibm.com>,
linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
Oleksandr Natalenko <oleksandr@natalenko.name>
Subject: [PATCH] tpm/eventlog: Don't abort tpm_read_log on faulty ACPI config
Date: Mon, 20 Sep 2021 22:34:47 +0200 [thread overview]
Message-ID: <20210920203447.4124005-1-morten@linderud.pw> (raw)
Some vendors report faulty values in the acpi TPM2 table. This causes
the function to abort with EIO and essentially short circuits the
tpm_read_log function as we never even attempt to read the EFI
configuration table for a log.
This changes the condition to only look for a positive return value,
else hands over the eventlog discovery to the EFI configuration table
which should hopefully work better.
It's unclear to me if there is a better solution to this then just
failing. However, I do not see any clear reason why we can't properly
fallback to the EFI configuration table.
The following hardware was used to test this issue on:
Framework Laptop (Pre-production)
BIOS: INSYDE Corp, Revision: 3.2
TPM Device: NTC, Firmware Revision: 7.2
Dump of the fault ACPI TPM2 table:
[000h 0000 4] Signature : "TPM2" [Trusted Platform Module hardware interface Table]
[004h 0004 4] Table Length : 0000004C
[008h 0008 1] Revision : 04
[009h 0009 1] Checksum : 2B
[00Ah 0010 6] Oem ID : "INSYDE"
[010h 0016 8] Oem Table ID : "TGL-ULT"
[018h 0024 4] Oem Revision : 00000002
[01Ch 0028 4] Asl Compiler ID : "ACPI"
[020h 0032 4] Asl Compiler Revision : 00040000
[024h 0036 2] Platform Class : 0000
[026h 0038 2] Reserved : 0000
[028h 0040 8] Control Address : 0000000000000000
[030h 0048 4] Start Method : 06 [Memory Mapped I/O]
[034h 0052 12] Method Parameters : 00 00 00 00 00 00 00 00 00 00 00 00
[040h 0064 4] Minimum Log Length : 00010000
[044h 0068 8] Log Address : 000000004053D000
Signed-off-by: Morten Linderud <morten@linderud.pw>
---
drivers/char/tpm/eventlog/acpi.c | 5 +++--
drivers/char/tpm/eventlog/common.c | 6 +++++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/char/tpm/eventlog/acpi.c b/drivers/char/tpm/eventlog/acpi.c
index 1b18ce5ebab1..9ce39cdb0bd8 100644
--- a/drivers/char/tpm/eventlog/acpi.c
+++ b/drivers/char/tpm/eventlog/acpi.c
@@ -136,8 +136,10 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
ret = -EIO;
virt = acpi_os_map_iomem(start, len);
- if (!virt)
+ if (!virt) {
+ dev_warn(&chip->dev, "%s: Failed to map acpi memory\n", __func__);
goto err;
+ }
memcpy_fromio(log->bios_event_log, virt, len);
@@ -145,7 +147,6 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
if (chip->flags & TPM_CHIP_FLAG_TPM2 &&
!tpm_is_tpm2_log(log->bios_event_log, len)) {
- /* try EFI log next */
ret = -ENODEV;
goto err;
}
diff --git a/drivers/char/tpm/eventlog/common.c b/drivers/char/tpm/eventlog/common.c
index 8512ec76d526..f64256bc2f89 100644
--- a/drivers/char/tpm/eventlog/common.c
+++ b/drivers/char/tpm/eventlog/common.c
@@ -83,7 +83,11 @@ static int tpm_read_log(struct tpm_chip *chip)
}
rc = tpm_read_log_acpi(chip);
- if (rc != -ENODEV)
+ /*
+ * only return if we found a log else we try look for a
+ * log in the EFI configuration table
+ */
+ if (rc > 0)
return rc;
rc = tpm_read_log_efi(chip);
--
2.33.0
next reply other threads:[~2021-09-20 20:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 20:34 Morten Linderud [this message]
2021-09-21 18:58 ` [PATCH] tpm/eventlog: Don't abort tpm_read_log on faulty ACPI config Jarkko Sakkinen
2021-09-21 19:27 ` Morten Linderud
2022-10-04 22:40 ` Jarkko Sakkinen
2022-10-05 9:31 ` Morten Linderud
2022-10-05 21:07 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210920203447.4124005-1-morten@linderud.pw \
--to=morten@linderud.pw \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr@natalenko.name \
--cc=peterhuewe@gmx.de \
--cc=stefanb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).