summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorXin Xiong <xiongx18@fudan.edu.cn>2022-04-28 06:39:08 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-25 12:15:36 +0300
commitf4d5c7796571624e3f380b447ada52834270a287 (patch)
tree7a74234db42c5efde9ac3c4e493f7476d1bbce04 /security
parent7af35951404b134731926cf80a218db7b1795ae9 (diff)
downloadlinux-f4d5c7796571624e3f380b447ada52834270a287.tar.xz
apparmor: fix reference count leak in aa_pivotroot()
commit 11c3627ec6b56c1525013f336f41b79a983b4d46 upstream. The aa_pivotroot() function has a reference counting bug in a specific path. When aa_replace_current_label() returns on success, the function forgets to decrement the reference count of “target”, which is increased earlier by build_pivotroot(), causing a reference leak. Fix it by decreasing the refcount of “target” in that path. Fixes: 2ea3ffb7782a ("apparmor: add mount mediation") Co-developed-by: Xiyu Yang <xiyuyang19@fudan.edu.cn> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn> Co-developed-by: Xin Tan <tanxin.ctf@gmail.com> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com> Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/mount.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/security/apparmor/mount.c b/security/apparmor/mount.c
index ec15bee2046c..85dc8a548c4b 100644
--- a/security/apparmor/mount.c
+++ b/security/apparmor/mount.c
@@ -686,6 +686,7 @@ int aa_pivotroot(struct aa_label *label, const struct path *old_path,
aa_put_label(target);
goto out;
}
+ aa_put_label(target);
} else
/* already audited error */
error = PTR_ERR(target);