]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
apparmor: fix reference count leak in aa_pivotroot()
authorXin Xiong <xiongx18@fudan.edu.cn>
Thu, 28 Apr 2022 03:39:08 +0000 (11:39 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 17 Oct 2022 09:57:15 +0000 (11:57 +0200)
BugLink: https://bugs.launchpad.net/bugs/1990564
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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
security/apparmor/mount.c

index 23aafe68d49a956dd51484127bcb0e77c72cee3c..f7bb47daf2ad686de8bca3b3576ebda17450b899 100644 (file)
@@ -719,6 +719,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);