From: John Johansen <john.johansen@canonical.com>
To: Wentao Liang <vulab@iscas.ac.cn>, apparmor@lists.ubuntu.com
Cc: jmorris@namei.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, paul@paul-moore.com,
serge@hallyn.com, stable@vger.kernel.org
Subject: Re: [PATCH] apparmor: Fix namespace reference leak in __aa_find_or_create_ns()
Date: Tue, 27 Oct 2026 14:06:22 -0700 [thread overview]
Message-ID: <9c8f370b-fe0f-48ea-a8ba-2b0631bf7c3b@canonical.com> (raw)
In-Reply-To: <20260917164302.2162938-1-vulab@iscas.ac.cn>
On 9/17/26 09:43, Wentao Liang wrote:
> When the namespace already exists, the reference taken by aa_get_ns() is
> overwritten with ERR_PTR(-EEXIST) without being released. The caller in
> apparmorfs.c clears ns on IS_ERR() and so cannot drop it either, leaking
> the reference on every mkdir of an existing namespace.
>
> Release the reference before returning -EEXIST.
>
> Fixes: 73688d1ed0b8 ("apparmor: refactor prepare_ns() and make usable from different views")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Acked-by: John Johansen <john.johansen@canonical.com>
I have been pulled this into the apparmor tree
> ---
> security/apparmor/policy_ns.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/security/apparmor/policy_ns.c b/security/apparmor/policy_ns.c
> index 5a907a875d8f..c423f4504d4d 100644
> --- a/security/apparmor/policy_ns.c
> +++ b/security/apparmor/policy_ns.c
> @@ -267,8 +267,10 @@ struct aa_ns *__aa_find_or_create_ns(struct aa_ns *parent, const char *name,
> ns = aa_get_ns(__aa_find_ns(&parent->sub_ns, name));
> if (!ns)
> ns = __aa_create_ns(parent, name, dir);
> - else
> + else {
> + aa_put_ns(ns);
> ns = ERR_PTR(-EEXIST);
> + }
>
> /* return ref */
> return ns;
prev parent reply other threads:[~2026-10-27 21:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 16:43 Wentao Liang
2026-10-27 21:06 ` John Johansen [this message]
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9c8f370b-fe0f-48ea-a8ba-2b0631bf7c3b@canonical.com \
--to=john.johansen@canonical.com \
--cc=apparmor@lists.ubuntu.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®