[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241102152226.2593598-3-jarkko@kernel.org>
Date: Sat, 2 Nov 2024 17:22:19 +0200
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Peter Huewe <peterhuewe@....de>,
Jarkko Sakkinen <jarkko@...nel.org>,
Jason Gunthorpe <jgg@...pe.ca>
Cc: x86@...nel.org,
"Daniel P. Smith" <dpsmith@...rtussolutions.com>,
Ross Philipson <ross.philipson@...cle.com>,
Ard Biesheuvel <ardb@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-integrity@...r.kernel.org (open list:TPM DEVICE DRIVER),
linux-kernel@...r.kernel.org (open list)
Subject: [RFC PATCH 2/4] tpm, tpm_tis: Address positive localities in tpm_tis_request_locality()
From: "Daniel P. Smith" <dpsmith@...rtussolutions.com>
Validate that the input locality is within the correct range, as specified
by TCG standards, and increase the locality count also for the positive
localities.
Signed-off-by: Daniel P. Smith <dpsmith@...rtussolutions.com>
Signed-off-by: Ross Philipson <ross.philipson@...cle.com>
Signed-off-by: Jarkko Sakkinen <jarkko@...nel.org>
---
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 c58f360fb4a4..c86100ad743a 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -234,10 +234,13 @@ static int tpm_tis_request_locality(struct tpm_chip *chip, int l)
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
int ret = 0;
+ if (l < 0 || l > TPM_MAX_LOCALITY)
+ return -EINVAL;
+
mutex_lock(&priv->locality_count_mutex);
if (priv->locality_count == 0)
ret = __tpm_tis_request_locality(chip, l);
- if (!ret)
+ if (ret >= 0)
priv->locality_count++;
mutex_unlock(&priv->locality_count_mutex);
return ret;
--
2.47.0
Powered by blists - more mailing lists