Commit 10cd6758 authored by Thorsten Blum's avatar Thorsten Blum Committed by Kees Cook
Browse files

exec: use strnlen() in __set_task_comm



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

Signed-off-by: default avatarThorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260401152039.724811-3-thorsten.blum@linux.dev


Signed-off-by: default avatarKees Cook <kees@kernel.org>
parent 4ced4cf5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1074,7 +1074,7 @@ static int unshare_sighand(struct task_struct *me)
 */
void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec)
{
	size_t len = min(strlen(buf), sizeof(tsk->comm) - 1);
	size_t len = strnlen(buf, sizeof(tsk->comm) - 1);

	trace_task_rename(tsk, buf);
	memcpy(tsk->comm, buf, len);