diff options
author | Danila Chernetsov <listdansp@mail.ru> | 2023-04-04 21:05:49 +0200 |
---|---|---|
committer | John Johansen <john.johansen@canonical.com> | 2023-07-06 19:58:49 +0200 |
commit | 000518bc5aef25d3f703592a0296d578c98b1517 (patch) | |
tree | 2d0084a1a277c289a5f6bec0bcb6b6b726d83f1a /security/apparmor | |
parent | apparmor: Return directly after a failed kzalloc() in two functions (diff) | |
download | linux-000518bc5aef25d3f703592a0296d578c98b1517.tar.xz linux-000518bc5aef25d3f703592a0296d578c98b1517.zip |
apparmor: fix missing error check for rhashtable_insert_fast
rhashtable_insert_fast() could return err value when memory allocation is
failed. but unpack_profile() do not check values and this always returns
success value. This patch just adds error check code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: e025be0f26d5 ("apparmor: support querying extended trusted helper extra data")
Signed-off-by: Danila Chernetsov <listdansp@mail.ru>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security/apparmor')
-rw-r--r-- | security/apparmor/policy_unpack.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c index 70caa444d9f8..22137fef9147 100644 --- a/security/apparmor/policy_unpack.c +++ b/security/apparmor/policy_unpack.c @@ -1035,8 +1035,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) goto fail; } - rhashtable_insert_fast(profile->data, &data->head, - profile->data->p); + if (rhashtable_insert_fast(profile->data, &data->head, + profile->data->p)) { + kfree_sensitive(data->key); + kfree_sensitive(data); + info = "failed to insert data to table"; + goto fail; + } } if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) { |