Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] tpm: Check return value of crypto_kpp_set_secret()
@ 2026-10-25 21:11 Eric Biggers
  2026-10-25 22:12 ` Jarkko Sakkinen
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Biggers @ 2026-10-25 21:11 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, James Bottomley
  Cc: linux-integrity, linux-crypto, Eric Biggers, stable

crypto_kpp_set_secret() can fail, for example if the kernel is booted
with fips=1 and the broken-by-design FIPS RNG used for ECC private key
generation doesn't feel like generating random bytes at the moment.
Check for error, cancelling the TPM session creation rather than
proceeding with a zero or uninitialized private key.

Fixes: 699e3efd6c64 ("tpm: Add HMAC session start and end functions")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
 drivers/char/tpm/tpm2-sessions.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm2-sessions.c b/drivers/char/tpm/tpm2-sessions.c
index ca1e2bf424e14..2aaaad69760dc 100644
--- a/drivers/char/tpm/tpm2-sessions.c
+++ b/drivers/char/tpm/tpm2-sessions.c
@@ -527,7 +527,9 @@ static int tpm_buf_append_salt(struct tpm_buf *buf, struct tpm_chip *chip,
 	}
 	crypto_ecdh_encode_key(encoded_key, buf_len, &p);
 	/* this generates a random private key */
-	crypto_kpp_set_secret(kpp, encoded_key, buf_len);
+	rc = crypto_kpp_set_secret(kpp, encoded_key, buf_len);
+	if (rc)
+		goto err_free_kpp;
 
 	/* salt is now the public point of this private key */
 	req = kpp_request_alloc(kpp, GFP_KERNEL);

base-commit: 21a7f44fd0765fcc5194130b28767786eba1d1e7
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-26  0:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-25 21:11 [PATCH] tpm: Check return value of crypto_kpp_set_secret() Eric Biggers
2026-10-25 22:12 ` Jarkko Sakkinen
2026-10-25 22:47   ` Eric Biggers
2026-10-25 23:11     ` Jarkko Sakkinen
2026-10-25 23:28       ` Jarkko Sakkinen
2026-10-25 23:40         ` Eric Biggers
2026-10-26  0:32           ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox