From: Eric Biggers Date: Wed, 9 Oct 2019 23:34:17 +0000 (-0700) Subject: fscrypt: zeroize fscrypt_info before freeing X-Git-Tag: v5.15~5111^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f99756dab5ba23e5dc74cd4ad24edd53af39beb;p=platform%2Fkernel%2Flinux-starfive.git fscrypt: zeroize fscrypt_info before freeing 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. Signed-off-by: Eric Biggers --- diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index 8eb5a0e..b03b336 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -327,6 +327,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); }