aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tgr192.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-09-07 17:23:38 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-10-17 11:44:07 -0400
commit7185ad2672a7d50bc384de0e38d90b75d99f3d82 (patch)
treebfad2f926347d9f23bc1e014ab347192e7592661 /crypto/tgr192.c
parentd4c5efdb97773f59a2b711754ca0953f24516739 (diff)
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/tgr192.c')
-rw-r--r--crypto/tgr192.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/tgr192.c b/crypto/tgr192.c
index 87403556fd0b..3c7af0d1ff7a 100644
--- a/crypto/tgr192.c
+++ b/crypto/tgr192.c
@@ -612,7 +612,7 @@ static int tgr160_final(struct shash_desc *desc, u8 * out)
612 612
613 tgr192_final(desc, D); 613 tgr192_final(desc, D);
614 memcpy(out, D, TGR160_DIGEST_SIZE); 614 memcpy(out, D, TGR160_DIGEST_SIZE);
615 memset(D, 0, TGR192_DIGEST_SIZE); 615 memzero_explicit(D, TGR192_DIGEST_SIZE);
616 616
617 return 0; 617 return 0;
618} 618}
@@ -623,7 +623,7 @@ static int tgr128_final(struct shash_desc *desc, u8 * out)
623 623
624 tgr192_final(desc, D); 624 tgr192_final(desc, D);
625 memcpy(out, D, TGR128_DIGEST_SIZE); 625 memcpy(out, D, TGR128_DIGEST_SIZE);
626 memset(D, 0, TGR192_DIGEST_SIZE); 626 memzero_explicit(D, TGR192_DIGEST_SIZE);
627 627
628 return 0; 628 return 0;
629} 629}