Commit 2bc73505 authored by Fedor Pchelkin's avatar Fedor Pchelkin Committed by John Johansen

apparmor: use kvfree_sensitive to free data->data

Inside unpack_profile() data->data is allocated using kvmemdup() so it
should be freed with the corresponding kvfree_sensitive().

Also add missing data->data release for rhashtable insertion failure path
in unpack_profile().

Found by Linux Verification Center (linuxtesting.org).

Fixes: e025be0f ("apparmor: support querying extended trusted helper extra data")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent fce09ea3
...@@ -225,7 +225,7 @@ static void aa_free_data(void *ptr, void *arg) ...@@ -225,7 +225,7 @@ static void aa_free_data(void *ptr, void *arg)
{ {
struct aa_data *data = ptr; struct aa_data *data = ptr;
kfree_sensitive(data->data); kvfree_sensitive(data->data, data->size);
kfree_sensitive(data->key); kfree_sensitive(data->key);
kfree_sensitive(data); kfree_sensitive(data);
} }
......
...@@ -1071,6 +1071,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) ...@@ -1071,6 +1071,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
if (rhashtable_insert_fast(profile->data, &data->head, if (rhashtable_insert_fast(profile->data, &data->head,
profile->data->p)) { profile->data->p)) {
kvfree_sensitive(data->data, data->size);
kfree_sensitive(data->key); kfree_sensitive(data->key);
kfree_sensitive(data); kfree_sensitive(data);
info = "failed to insert data to table"; info = "failed to insert data to table";
......
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