Skip to content

Commit 200f091

Browse files
committed
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@oracle.com> Closes: https://lore.kernel.org/all/d122ece6-3606-49de-ae4d-8da88846bef2@oracle.com Fixes: c114e99 ("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>
1 parent 8cf0b93 commit 200f091

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/linux/coredump.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ extern void do_coredump(const kernel_siginfo_t *siginfo);
5252
#define __COREDUMP_PRINTK(Level, Format, ...) \
5353
do { \
5454
char comm[TASK_COMM_LEN]; \
55-
\
56-
get_task_comm(comm, current); \
55+
/* This will always be NUL terminated. */ \
56+
memcpy(comm, current->comm, sizeof(comm)); \
5757
printk_ratelimited(Level "coredump: %d(%*pE): " Format "\n", \
5858
task_tgid_vnr(current), (int)strlen(comm), comm, ##__VA_ARGS__); \
5959
} while (0) \

0 commit comments

Comments
 (0)