diff options
author | Arvind Sankar <nivedita@alum.mit.edu> | 2020-10-25 15:31:14 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2020-10-30 07:35:03 +0100 |
commit | 1762818f25f3f99c5083caa13d69e5e5aa2e4b6f (patch) | |
tree | 09fd538f8085ed4d5f944eaa50eaabb6177fa9e9 /lib/crypto | |
parent | crypto: omap-aes - fix the reference count leak of omap device (diff) | |
download | linux-1762818f25f3f99c5083caa13d69e5e5aa2e4b6f.tar.xz linux-1762818f25f3f99c5083caa13d69e5e5aa2e4b6f.zip |
crypto: lib/sha256 - Use memzero_explicit() for clearing state
Without the barrier_data() inside memzero_explicit(), the compiler may
optimize away the state-clearing if it can tell that the state is not
used afterwards. At least in lib/crypto/sha256.c:__sha256_final(), the
function can get inlined into sha256(), in which case the memset is
optimized away.
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/crypto')
-rw-r--r-- | lib/crypto/sha256.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/crypto/sha256.c b/lib/crypto/sha256.c index 2321f6cb322f..d43bc39ab05e 100644 --- a/lib/crypto/sha256.c +++ b/lib/crypto/sha256.c @@ -265,7 +265,7 @@ static void __sha256_final(struct sha256_state *sctx, u8 *out, int digest_words) put_unaligned_be32(sctx->state[i], &dst[i]); /* Zeroize sensitive information. */ - memset(sctx, 0, sizeof(*sctx)); + memzero_explicit(sctx, sizeof(*sctx)); } void sha256_final(struct sha256_state *sctx, u8 *out) |