Commit 91080180 authored by Jason A. Donenfeld's avatar Jason A. Donenfeld Committed by David Howells

security/keys: properly zero out sensitive key material in big_key

Error paths forgot to zero out sensitive material, so this patch changes
some kfrees into a kzfrees.
Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarEric Biggers <ebiggers3@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: security@kernel.org
Cc: stable@vger.kernel.org
parent e007ce9c
...@@ -195,7 +195,7 @@ int big_key_preparse(struct key_preparsed_payload *prep) ...@@ -195,7 +195,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
*path = file->f_path; *path = file->f_path;
path_get(path); path_get(path);
fput(file); fput(file);
kfree(data); kzfree(data);
} else { } else {
/* Just store the data in a buffer */ /* Just store the data in a buffer */
void *data = kmalloc(datalen, GFP_KERNEL); void *data = kmalloc(datalen, GFP_KERNEL);
...@@ -211,9 +211,9 @@ int big_key_preparse(struct key_preparsed_payload *prep) ...@@ -211,9 +211,9 @@ int big_key_preparse(struct key_preparsed_payload *prep)
err_fput: err_fput:
fput(file); fput(file);
err_enckey: err_enckey:
kfree(enckey); kzfree(enckey);
error: error:
kfree(data); kzfree(data);
return ret; return ret;
} }
...@@ -227,7 +227,7 @@ void big_key_free_preparse(struct key_preparsed_payload *prep) ...@@ -227,7 +227,7 @@ void big_key_free_preparse(struct key_preparsed_payload *prep)
path_put(path); path_put(path);
} }
kfree(prep->payload.data[big_key_data]); kzfree(prep->payload.data[big_key_data]);
} }
/* /*
...@@ -259,7 +259,7 @@ void big_key_destroy(struct key *key) ...@@ -259,7 +259,7 @@ void big_key_destroy(struct key *key)
path->mnt = NULL; path->mnt = NULL;
path->dentry = NULL; path->dentry = NULL;
} }
kfree(key->payload.data[big_key_data]); kzfree(key->payload.data[big_key_data]);
key->payload.data[big_key_data] = NULL; key->payload.data[big_key_data] = NULL;
} }
...@@ -328,7 +328,7 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen) ...@@ -328,7 +328,7 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen)
err_fput: err_fput:
fput(file); fput(file);
error: error:
kfree(data); kzfree(data);
} else { } else {
ret = datalen; ret = datalen;
if (copy_to_user(buffer, key->payload.data[big_key_data], if (copy_to_user(buffer, key->payload.data[big_key_data],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment