[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241219023452.69907-5-laoar.shao@gmail.com>
Date: Thu, 19 Dec 2024 10:34:51 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: akpm@...ux-foundation.org
Cc: torvalds@...ux-foundation.org,
pmladek@...e.com,
kvalo@...nel.org,
bp@...en8.de,
andriy.shevchenko@...ux.intel.com,
linux-mm@...ck.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,
Yafang Shao <laoar.shao@...il.com>,
Paul Moore <paul@...l-moore.com>,
Kees Cook <kees@...nel.org>,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>
Subject: [PATCH v2 4/5] security: Remove get_task_comm() and print task comm directly
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>
Reviewed-by: Paul Moore <paul@...l-moore.com>
Acked-by: Kees Cook <kees@...nel.org>
Cc: James Morris <jmorris@...ei.org>
Cc: "Serge E. Hallyn" <serge@...lyn.com>
---
security/yama/yama_lsm.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index e1a5e13ea269..1a2d02fee09b 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 */
@@ -86,8 +85,7 @@ static void report_access(const char *access, struct task_struct *target,
*/
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);
+ access, target->comm, target->pid, agent->comm, agent->pid);
return;
}
--
2.43.5
Powered by blists - more mailing lists