fscrypt: Explicitly zeroize sw_secret in error path
Eric Biggers
maintainerPATCH 1/1 fscrypt: Explicitly zeroize sw_secret in error path
Explicitly zeroize the sw_secret array in the case where fscrypt_derive_sw_secret() fails, in case anything was written to it. Doesn't really matter, but this came up in a code review.
Signed-off-by Eric Biggers <[email protected]>
--- fs/crypto/keyring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/crypto/keyring.c +3 -1
@@ -561,8 +561,10 @@ static int add_master_key(struct super_block *sb,if (secret->is_hw_wrapped) { err =fscrypt_derive_sw_secret (sb, secret->bytes, secret->size, sw_secret); -if (err) +if (err) { +memzero_explicit (sw_secret,sizeof (sw_secret));return err; + } kdf_key = sw_secret; kdf_key_size =sizeof (sw_secret);/*
base-commit: ccc4d9f8912a5d9f519a34c3633fe53c8f9b429e
Signature · 1 line
2.56.0.218.g1ec904b173-goog
Quoted 8 lines · Eric Biggers
Explicitly zeroize the
sw_secretarray in the case wherefscrypt_derive_sw_secret()fails, in case anything was written to it. Doesn't really matter, but this came up in a code review.Signed-off-by Eric Biggers <[email protected]>--- fs/crypto/keyring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Applied to https://git.kernel.org/pub/scm/fs/fscrypt/linux.git/log/?h=for-next
- Eric