All of
 help / color / mirror / Atom feed
From: Xin Xiong <>
To: John Johansen <>,
	James Morris <>,
	"Serge E. Hallyn" <>,
	Seth Arnold <>,,
Cc:, Xin Xiong <>,
	Xiyu Yang <>,
	Xin Tan <>
Subject: [PATCH] apparmor: fix reference count leak in aa_pivotroot()
Date: Thu, 28 Apr 2022 11:39:08 +0800	[thread overview]
Message-ID: <> (raw)

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 <>
Signed-off-by: Xiyu Yang <>
Co-developed-by: Xin Tan <>
Signed-off-by: Xin Tan <>
Signed-off-by: Xin Xiong <>
 security/apparmor/mount.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/security/apparmor/mount.c b/security/apparmor/mount.c
index aa6fcfde3051..d0b19ab9137d 100644
--- a/security/apparmor/mount.c
+++ b/security/apparmor/mount.c
@@ -718,6 +718,7 @@ int aa_pivotroot(struct aa_label *label, const struct path *old_path,
 			goto out;
+		aa_put_label(target);
 	} else
 		/* already audited error */
 		error = PTR_ERR(target);

             reply	other threads:[~2022-04-28  3:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  3:39 Xin Xiong [this message]
2022-05-19  8:58 ` John Johansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] apparmor: fix reference count leak in aa_pivotroot()' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.