dm crypt: use memzero_explicit for on-stack buffer
authorMilan Broz <gmazyland@gmail.com>
Sat, 22 Nov 2014 08:36:04 +0000 (09:36 +0100)
committerAlex Shi <alex.shi@linaro.org>
Tue, 23 Jun 2015 07:28:33 +0000 (15:28 +0800)
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 <gmazyland@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
(cherry picked from commit 1a71d6ffe18c0d0f03fc8531949cc8ed41d702ee)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
drivers/md/dm-crypt.c

index fc8c10d2e6e2b86869e493a0154281d5ec1c428b..421f8118c5871f2b66caa3e2d2cc1db97ed58f2e 100644 (file)
@@ -711,7 +711,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;
 }