[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHC9VhSHP4zt-GtOWgjzC+vVJriJh32_T+7dt0uBtTLXuoYvnQ@mail.gmail.com>
Date: Mon, 16 Dec 2024 18:02:47 -0500
From: Paul Moore <paul@...l-moore.com>
To: Yafang Shao <laoar.shao@...il.com>
Cc: torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, linux-security-module@...r.kernel.org,
x86@...nel.org, linux-snps-arc@...ts.infradead.org,
linux-wireless@...r.kernel.org, intel-gfx@...ts.freedesktop.org,
intel-xe@...ts.freedesktop.org, nouveau@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, ocfs2-devel@...ts.linux.dev,
Kees Cook <kees@...nel.org>, James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>
Subject: Re: [PATCH 5/7] security: Replace get_task_comm() with %pTN
On Fri, Dec 13, 2024 at 12:47 AM Yafang Shao <laoar.shao@...il.com> wrote:
>
> Since task->comm is guaranteed to be NUL-terminated, we can print it
> directly without the need to copy it into a separate buffer. This
> simplifies the code and avoids unnecessary operations.
>
> Signed-off-by: Yafang Shao <laoar.shao@...il.com>
> Cc: Kees Cook <kees@...nel.org>
> Cc: Paul Moore <paul@...l-moore.com>
> Cc: James Morris <jmorris@...ei.org>
> Cc: "Serge E. Hallyn" <serge@...lyn.com>
> ---
> security/yama/yama_lsm.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
You need to wait for Kees' ACK, but this looks okay to me.
Reviewed-by: Paul Moore <paul@...l-moore.com>
> diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
> index e1a5e13ea269..4bdfa51ea6fd 100644
> --- a/security/yama/yama_lsm.c
> +++ b/security/yama/yama_lsm.c
> @@ -76,7 +76,6 @@ static void report_access(const char *access, struct task_struct *target,
> struct task_struct *agent)
> {
> struct access_report_info *info;
> - char agent_comm[sizeof(agent->comm)];
>
> assert_spin_locked(&target->alloc_lock); /* for target->comm */
>
> @@ -85,9 +84,8 @@ static void report_access(const char *access, struct task_struct *target,
> * Imagine angry ranting about procfs here.
> */
> pr_notice_ratelimited(
> - "ptrace %s of \"%s\"[%d] was attempted by \"%s\"[%d]\n",
> - access, target->comm, target->pid,
> - get_task_comm(agent_comm, agent), agent->pid);
> + "ptrace %s of \"%pTN\"[%d] was attempted by \"%pTN\"[%d]\n",
> + access, target, target->pid, agent, agent->pid);
> return;
> }
>
> --
> 2.43.5
--
paul-moore.com
Powered by blists - more mailing lists