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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2015 18:30:18 +0000 (10:30 -0800)
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 <gmazyland@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-crypt.c

index fc93b9330af4f7195768b67525fd504dd8701395..08981be7baa183dbe963b6e38cd4866f34e278a7 100644 (file)
@@ -705,7 +705,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;
 }