Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

exec: use strnlen() in __set_task_comm

Use strnlen() to limit source string scanning to 'TASK_COMM_LEN - 1'
bytes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260401152039.724811-3-thorsten.blum@linux.dev
Signed-off-by: Kees Cook <kees@kernel.org>

authored by

Thorsten Blum and committed by
Kees Cook
10cd6758 4ced4cf5

+1 -1
+1 -1
fs/exec.c
··· 1074 1074 */ 1075 1075 void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec) 1076 1076 { 1077 - size_t len = min(strlen(buf), sizeof(tsk->comm) - 1); 1077 + size_t len = strnlen(buf, sizeof(tsk->comm) - 1); 1078 1078 1079 1079 trace_task_rename(tsk, buf); 1080 1080 memcpy(tsk->comm, buf, len);