From: John Johansen <john.johansen@canonical.com>
To: Thorsten Blum <thorsten.blum@linux.dev>,
Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>
Cc: apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] apparmor: Replace deprecated strcpy in d_namespace_path
Date: Thu, 6 Nov 2025 06:54:11 -0800 [thread overview]
Message-ID: <f169ae3a-d50d-4eb3-a977-bb16270527bd@canonical.com> (raw)
In-Reply-To: <20251106145138.2123-2-thorsten.blum@linux.dev>
On 11/6/25 06:51, Thorsten Blum wrote:
> strcpy() is deprecated; replace it with a direct '/' assignment. The
> buffer is already NUL-terminated, so there is no need to copy an
> additional NUL terminator as strcpy() did.
>
> Update the comment and add the local variable 'is_root' for clarity.
>
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
hey Thorsten,
sorry I have just been swamped, and traveling, ...
I will start on the patch backlog tonight
> ---
> security/apparmor/path.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/security/apparmor/path.c b/security/apparmor/path.c
> index d6c74c357ffd..65a0ca5cc1bd 100644
> --- a/security/apparmor/path.c
> +++ b/security/apparmor/path.c
> @@ -164,12 +164,15 @@ static int d_namespace_path(const struct path *path, char *buf, char **name,
> }
>
> out:
> - /*
> - * Append "/" to the pathname. The root directory is a special
> - * case; it already ends in slash.
> + /* Append "/" to directory paths, except for root "/" which
> + * already ends in a slash.
> */
> - if (!error && isdir && ((*name)[1] != '\0' || (*name)[0] != '/'))
> - strcpy(&buf[aa_g_path_max - 2], "/");
> + if (!error && isdir) {
> + bool is_root = (*name)[0] == '/' && (*name)[1] == '\0';
> +
> + if (!is_root)
> + buf[aa_g_path_max - 2] = '/';
> + }
>
> return error;
> }
prev parent reply other threads:[~2025-11-06 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 14:51 Thorsten Blum
2025-11-06 14:54 ` 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=f169ae3a-d50d-4eb3-a977-bb16270527bd@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=thorsten.blum@linux.dev \
/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®