Thread (31 messages) 31 messages, 4 authors, 2024-08-29
STALE638d
Revisions (11)
  1. v3 [diff vs current]
  2. v4 [diff vs current]
  3. v6 [diff vs current]
  4. v8 [diff vs current]
  5. v9 [diff vs current]
  6. v10 current
  7. v11 [diff vs current]
  8. v12 [diff vs current]
  9. v13 [diff vs current]
  10. v13 [diff vs current]
  11. v14 [diff vs current]

[PATCH v10 14/20] tpm: Protect against locality counter underflow

From: Ross Philipson <hidden>
Date: 2024-08-26 22:43:37
Also in: kexec, linux-crypto, linux-efi, linux-integrity, lkml
Subsystem: the rest, tpm device driver · Maintainers: Linus Torvalds, Peter Huewe, Jarkko Sakkinen

From: "Daniel P. Smith" <redacted>

Commit 933bfc5ad213 introduced the use of a locality counter to control when a
locality request is allowed to be sent to the TPM. In the commit, the counter
is indiscriminately decremented. Thus creating a situation for an integer
underflow of the counter.

Signed-off-by: Daniel P. Smith <redacted>
Signed-off-by: Ross Philipson <redacted>
Reported-by: Kanth Ghatraju <redacted>
---
 drivers/char/tpm/tpm_tis_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index fdef214b9f6b..a6967f312837 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -180,7 +180,10 @@ static int tpm_tis_relinquish_locality(struct tpm_chip *chip, int l)
 	struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
 
 	mutex_lock(&priv->locality_count_mutex);
-	priv->locality_count--;
+	if (priv->locality_count > 0)
+		priv->locality_count--;
+	else
+		pr_info("Invalid: locality count dropped below zero\n");
 	if (priv->locality_count == 0)
 		__tpm_tis_relinquish_locality(priv, l);
 	mutex_unlock(&priv->locality_count_mutex);
-- 
2.39.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help