Skip to contentSkip to conversation

fscrypt: zeroize fscrypt_info before freeing

PATCH Applied Eric Biggers 1 participant 2 messages Oct 9, 2019 – Oct 21, 2019 fscrypt: file system level encryption support

lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 fscrypt: zeroize fscrypt_info before freeing

From: Eric Biggers <[email protected]>

memset the struct fscrypt_info to zero before freeing. This isn't really needed currently, since there's no secret key directly in the fscrypt_info. But there's a decent chance that someone will add such a field in the future, e.g. in order to use an API that takes a raw key such as siphash(). So it's good to do this as a hardening measure.

---
 fs/crypto/keysetup.c | 1 +
 1 file changed, 1 insertion(+)
fs/crypto/keysetup.c +1 -0
index df3e1c8653884..0ba33e010312f 100644
@@ -325,6 +325,7 @@ static void put_crypt_info(struct fscrypt_info *ci)
 			key_invalidate(key);
 		key_put(key);
 	}
+	memzero_explicit(ci, sizeof(*ci));
 	kmem_cache_free(fscrypt_info_cachep, ci);
 }
 
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
author maintainer Applied
#1 lore raw
Quoted 28 lines · Eric Biggers

From: Eric Biggers <[email protected]>

memset the struct fscrypt_info to zero before freeing. This isn't really needed currently, since there's no secret key directly in the fscrypt_info. But there's a decent chance that someone will add such a field in the future, e.g. in order to use an API that takes a raw key such as siphash(). So it's good to do this as a hardening measure.

---
 fs/crypto/keysetup.c | 1 +
 1 file changed, 1 insertion(+)
fs/crypto/keysetup.c +1 -0
index df3e1c8653884..0ba33e010312f 100644
@@ -325,6 +325,7 @@ static void put_crypt_info(struct fscrypt_info *ci)
 			key_invalidate(key);
 		key_put(key);
 	}
+	memzero_explicit(ci, sizeof(*ci));
 	kmem_cache_free(fscrypt_info_cachep, ci);
 }
 
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog

Applied to fscrypt.git for 5.5.

- Eric