2021-08-26 12:24:10

by Amir Mizinski

[permalink] [raw]
Subject: [PATCH v13 5/7] tpm: tpm_tis: verify TPM_STS register is valid after locality request

From: Amir Mizinski <[email protected]>

Issue could result when the TPM does not update TPM_STS register after
a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register
read occurs (tpm_tis_status(chip)).

Checking the next condition("if ((status & TPM_STS_COMMAND_READY) == 0)"),
the status will be at 0xFF and will be considered, wrongly, in "Ready"
state (by checking only one bit). However, at this moment the TPM is, in
fact, in "Idle" state and remains in "Idle" state because
"tpm_tis_ready(chip);" was not executed.

Suggested-by: Benoit Houyere <[email protected]>
Signed-off-by: Amir Mizinski <[email protected]>
---
drivers/char/tpm/tpm_tis_core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 4145758..d527c43 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -177,8 +177,14 @@ static int request_locality(struct tpm_chip *chip, int l)
} else {
/* wait for burstcount */
do {
- if (check_locality(chip, l))
+ if (check_locality(chip, l)) {
+ if (tpm_tis_wait_for_stat(chip, TPM_STS_GO, 0,
+ chip->timeout_c,
+ &priv->int_queue,
+ false) < 0)
+ return -ETIME;
return l;
+ }
tpm_msleep(TPM_TIMEOUT);
} while (time_before(jiffies, stop));
}
--
2.7.4


2021-08-26 16:05:30

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH v13 5/7] tpm: tpm_tis: verify TPM_STS register is valid after locality request

On Thu, 2021-08-26 at 14:19 +0300, [email protected] wrote:
> From: Amir Mizinski <[email protected]>
>
> Issue could result when the TPM does not update TPM_STS register after
> a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register
> read occurs (tpm_tis_status(chip)).

What does it mean when "issue results"?

I don't understand that part.

/Jarkko