Skip to content

Commit

Permalink
apparmor: Fix memleak in alloc_ns()
Browse files Browse the repository at this point in the history
[ Upstream commit e9e6fa4 ]

After changes in commit a1bd627 ("apparmor: share profile name on
replacement"), the hname member of struct aa_policy is not valid slab
object, but a subset of that, it can not be freed by kfree_sensitive(),
use aa_policy_destroy() to fix it.

Fixes: a1bd627 ("apparmor: share profile name on replacement")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Xiu Jianfeng authored and gregkh committed Dec 31, 2022
1 parent 7417cc5 commit 12695b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion security/apparmor/policy_ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static struct aa_ns *alloc_ns(const char *prefix, const char *name)
return ns;

fail_unconfined:
kfree_sensitive(ns->base.hname);
aa_policy_destroy(&ns->base);
fail_ns:
kfree_sensitive(ns);
return NULL;
Expand Down

0 comments on commit 12695b4

Please sign in to comment.