fscrypt: zeroize fscrypt_info before freeing
authorEric Biggers <ebiggers@google.com>
Wed, 9 Oct 2019 23:34:17 +0000 (16:34 -0700)
committerEric Biggers <ebiggers@google.com>
Mon, 21 Oct 2019 20:22:08 +0000 (13:22 -0700)
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 <ebiggers@google.com>
fs/crypto/keysetup.c

index 8eb5a0e..b03b336 100644 (file)
@@ -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);
 }