From: Milan Broz Date: Sat, 22 Nov 2014 08:36:04 +0000 (+0100) Subject: dm crypt: use memzero_explicit for on-stack buffer X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a6e37a9dcf822402ad1f9afc5a7bca0c98a486a1;p=karo-tx-linux.git dm crypt: use memzero_explicit for on-stack buffer commit 1a71d6ffe18c0d0f03fc8531949cc8ed41d702ee upstream. Use memzero_explicit to cleanup sensitive data allocated on stack to prevent the compiler from optimizing and removing memset() calls. Signed-off-by: Milan Broz Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 9533f835ce07..4a8d19d0a5a4 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -709,7 +709,7 @@ static int crypt_iv_tcw_whitening(struct crypt_config *cc, for (i = 0; i < ((1 << SECTOR_SHIFT) / 8); i++) crypto_xor(data + i * 8, buf, 8); out: - memset(buf, 0, sizeof(buf)); + memzero_explicit(buf, sizeof(buf)); return r; }