Skip to content

Commit 000518b

Browse files
DanCh2020jrjohansen
authored andcommitted
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: e025be0 ("apparmor: support querying extended trusted helper extra data") Signed-off-by: Danila Chernetsov <[email protected]> Signed-off-by: John Johansen <[email protected]>
1 parent 6d74679 commit 000518b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

security/apparmor/policy_unpack.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
10351035
goto fail;
10361036
}
10371037

1038-
rhashtable_insert_fast(profile->data, &data->head,
1039-
profile->data->p);
1038+
if (rhashtable_insert_fast(profile->data, &data->head,
1039+
profile->data->p)) {
1040+
kfree_sensitive(data->key);
1041+
kfree_sensitive(data);
1042+
info = "failed to insert data to table";
1043+
goto fail;
1044+
}
10401045
}
10411046

10421047
if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) {

0 commit comments

Comments
 (0)