diff options
author | Fedor Pchelkin <pchelkin@ispras.ru> | 2024-02-01 17:24:48 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-08-03 09:49:33 +0300 |
commit | 74b91a689b04cf70c9cf10320e7e7b952b2c0f30 (patch) | |
tree | 386b4508f3d8036d54fdcf9ae0ab9c11f445306c | |
parent | 37e9af4946a510b2a22a3990ebc3478248e84646 (diff) | |
download | linux-74b91a689b04cf70c9cf10320e7e7b952b2c0f30.tar.xz |
apparmor: use kvfree_sensitive to free data->data
commit 2bc73505a5cd2a18a7a542022722f136c19e3b87 upstream.
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: e025be0f26d5 ("apparmor: support querying extended trusted helper extra data")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | security/apparmor/policy.c | 2 | ||||
-rw-r--r-- | security/apparmor/policy_unpack.c | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c index c7b84fb56841..4ee5a450d118 100644 --- a/security/apparmor/policy.c +++ b/security/apparmor/policy.c @@ -187,7 +187,7 @@ static void aa_free_data(void *ptr, void *arg) { struct aa_data *data = ptr; - kfree_sensitive(data->data); + kvfree_sensitive(data->data, data->size); kfree_sensitive(data->key); kfree_sensitive(data); } diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c index 633e778ec369..17601235ff98 100644 --- a/security/apparmor/policy_unpack.c +++ b/security/apparmor/policy_unpack.c @@ -898,6 +898,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) if (rhashtable_insert_fast(profile->data, &data->head, profile->data->p)) { + kvfree_sensitive(data->data, data->size); kfree_sensitive(data->key); kfree_sensitive(data); info = "failed to insert data to table"; |