Skip to contentSkip to conversation

dm-crypt: use memzero_explicit for on-stack buffer

PATCH New Milan Broz 1 participant 1 message Nov 22, 2014 Device mapper

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 dm-crypt: use memzero_explicit for on-stack buffer

Use memzero_explicit to cleanup sensitive data allocated on stack to prevent compiler optimize and remove memset() calls.

---
 drivers/md/dm-crypt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-crypt.c +1 -1
index fc93b93..08981be 100644
@@ -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;
 }
 
Signature · 1 line
2.1.3