summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2024-09-28 14:08:31 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-08 09:56:49 +0100
commit4338831b831c76c9511b1f3aef64510b292da444 (patch)
tree9c04807e21cfd60d7ed48cbc26b926813d6e5ace
parentd914acc16b5910bf9b46e2e8b441569bfe180d1b (diff)
coredump: Do not lock during 'comm' reporting
[ Upstream commit 200f091c95bbc4b8660636bd345805c45d6eced7 ] 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@oracle.com> Closes: https://lore.kernel.org/all/d122ece6-3606-49de-ae4d-8da88846bef2@oracle.com Fixes: c114e9948c2b ("coredump: Standartize and fix logging") Tested-by: Vegard Nossum <vegard.nossum@oracle.com> Link: https://lore.kernel.org/r/20240928210830.work.307-kees@kernel.org Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--include/linux/coredump.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
index 45e598fe3476..77e6e195d1d6 100644
--- a/include/linux/coredump.h
+++ b/include/linux/coredump.h
@@ -52,8 +52,8 @@ extern void 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) \