summaryrefslogtreecommitdiff
path: root/crypto/vmac.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-09-07 23:23:38 +0200
committerTheodore Ts'o <tytso@mit.edu>2014-10-17 11:44:07 -0400
commit8ff8c72485c0d0bbb91377d33bbf016ae0744cd8 (patch)
tree5c6a430d6388c9dc49d4e4a3eebc662f5309dce0 /crypto/vmac.c
parent245c531351ef282b69bcd2bd7d46bfc79234f9b4 (diff)
downloadlinux-crypto-8ff8c72485c0d0bbb91377d33bbf016ae0744cd8.tar.gz
linux-crypto-8ff8c72485c0d0bbb91377d33bbf016ae0744cd8.zip
crypto: memzero_explicit - make sure to clear out sensitive data
Recently, in commit 13aa93c70e71 ("random: add and use memzero_explicit() for clearing data"), we have found that GCC may optimize some memset() cases away when it detects a stack variable is not being used anymore and going out of scope. This can happen, for example, in cases when we are clearing out sensitive information such as keying material or any e.g. intermediate results from crypto computations, etc. With the help of Coccinelle, we can figure out and fix such occurences in the crypto subsytem as well. Julia Lawall provided the following Coccinelle program: @@ type T; identifier x; @@ T x; ... when exists when any -memset +memzero_explicit (&x, -0, ...) ... when != x when strict @@ type T; identifier x; @@ T x[...]; ... when exists when any -memset +memzero_explicit (x, -0, ...) ... when != x when strict Therefore, make use of the drop-in replacement memzero_explicit() for exactly such cases instead of using memset(). Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Cc: Julia Lawall <julia.lawall@lip6.fr> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'crypto/vmac.c')
-rw-r--r--crypto/vmac.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/vmac.c b/crypto/vmac.c
index 2eb11a30..d84c24bd 100644
--- a/crypto/vmac.c
+++ b/crypto/vmac.c
@@ -613,7 +613,7 @@ static int vmac_final(struct shash_desc *pdesc, u8 *out)
}
mac = vmac(ctx->partial, ctx->partial_size, nonce, NULL, ctx);
memcpy(out, &mac, sizeof(vmac_t));
- memset(&mac, 0, sizeof(vmac_t));
+ memzero_explicit(&mac, sizeof(vmac_t));
memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx));
ctx->partial_size = 0;
return 0;