apparmor: Fix memleak in alloc_ns()
authorXiu Jianfeng <xiujianfeng@huawei.com>
Fri, 28 Oct 2022 12:33:20 +0000 (20:33 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:31 +0000 (13:32 +0100)
commit12695b4b76d437b9c0182a6f7dfb2248013a9daf
tree4d018fa36498f5c050caf94ab6db270db7c934fe
parent7417cc5151bc3394ad9a9d501282ea09b79b54b0
apparmor: Fix memleak in alloc_ns()

[ Upstream commit e9e6fa49dbab6d84c676666f3fe7d360497fd65b ]

After changes in commit a1bd627b46d1 ("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: a1bd627b46d1 ("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>
security/apparmor/policy_ns.c