Skip to content

Commit 10cd675

Browse files
tobluxkees
authored andcommitted
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 <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 4ced4cf commit 10cd675

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ static int unshare_sighand(struct task_struct *me)
10741074
*/
10751075
void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec)
10761076
{
1077-
size_t len = min(strlen(buf), sizeof(tsk->comm) - 1);
1077+
size_t len = strnlen(buf, sizeof(tsk->comm) - 1);
10781078

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

0 commit comments

Comments
 (0)