[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240928210830.work.307-kees@kernel.org>
Date: Sat, 28 Sep 2024 14:08:31 -0700
From: Kees Cook <kees@...nel.org>
To: Vegard Nossum <vegard.nossum@...cle.com>
Cc: Kees Cook <kees@...nel.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Allen Pais <apais@...ux.microsoft.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Roman Kisel <romank@...ux.microsoft.com>,
Xiaoming Ni <nixiaoming@...wei.com>,
Vijay Nag <nagvijay@...rosoft.com>,
linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: [PATCH] coredump: Do not lock during 'comm' reporting
The 'comm' member will always be NUL terminated, and this is not
fast-path, so we can just perform a direct memcpy during a coredump
instead of potentially deadlocking while holding the task struct lock.
Reported-by: Vegard Nossum <vegard.nossum@...cle.com>
Closes: https://lore.kernel.org/all/d122ece6-3606-49de-ae4d-8da88846bef2@oracle.com
Fixes: c114e9948c2b ("coredump: Standartize and fix logging")
Signed-off-by: Kees Cook <kees@...nel.org>
---
Cc: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: Allen Pais <apais@...ux.microsoft.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Roman Kisel <romank@...ux.microsoft.com>
Cc: Xiaoming Ni <nixiaoming@...wei.com>
Vegard, can you validate that this fixes the problem for you? I have
been wrecked by covid, so very slow to respond here. There's a related
thread about this locked, but we can just totally bypass it here.
---
include/linux/coredump.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
index edeb8532ce0f..a99079115a38 100644
--- a/include/linux/coredump.h
+++ b/include/linux/coredump.h
@@ -52,8 +52,8 @@ extern int do_coredump(const kernel_siginfo_t *siginfo);
#define __COREDUMP_PRINTK(Level, Format, ...) \
do { \
char comm[TASK_COMM_LEN]; \
- \
- get_task_comm(comm, current); \
+ /* This will always be NUL terminated. */ \
+ memcpy(comm, current->comm, sizeof(comm)); \
printk_ratelimited(Level "coredump: %d(%*pE): " Format "\n", \
task_tgid_vnr(current), (int)strlen(comm), comm, ##__VA_ARGS__); \
} while (0) \
--
2.34.1
Powered by blists - more mailing lists