* [PATCH v3 09/13] security: keys: trusted: always clear the hmac_sha1_ctx before returning
[not found] <20260910124138.417439-1-thuth@redhat.com>
@ 2026-09-10 12:41 ` Thomas Huth
0 siblings, 0 replies; only message in thread
From: Thomas Huth @ 2026-09-10 12:41 UTC (permalink / raw)
To: Eric Biggers, Herbert Xu, David S. Miller, Jason A. Donenfeld,
Ard Biesheuvel, James Bottomley, Jarkko Sakkinen, Mimi Zohar,
David Howells, Paul Moore, James Morris, Serge E. Hallyn
Cc: linux-crypto, linux-kernel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, linux-integrity, keyrings,
linux-security-module
Clear the hmac_sha1_ctx structure via __cleanup(hmac_sha1_zeroize_ctx)
to make sure that the function does not leak sensitive data on the stack
when returning without calling hmac_sha1_final().
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
security/keys/trusted-keys/trusted_tpm1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/keys/trusted-keys/trusted_tpm1.c b/security/keys/trusted-keys/trusted_tpm1.c
index bf0bf7f369705..e5a904b5c1946 100644
--- a/security/keys/trusted-keys/trusted_tpm1.c
+++ b/security/keys/trusted-keys/trusted_tpm1.c
@@ -101,7 +101,7 @@ static inline void dump_tpm_buf(unsigned char *buf)
static int TSS_rawhmac(unsigned char *digest, const unsigned char *key,
unsigned int keylen, ...)
{
- struct hmac_sha1_ctx hmac_ctx;
+ struct hmac_sha1_ctx hmac_ctx __cleanup(hmac_sha1_zeroize_ctx);
va_list argp;
unsigned int dlen;
unsigned char *data;
--
2.55.0
^ permalink raw reply related [flat|nested] only message in thread