execve updates for v7.1-rc1

- use strnlen() in __set_task_comm (Thorsten Blum)
 
 - update task_struct->comm comment (Thorsten Blum)
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQRSPkdeREjth1dHnSE2KwveOeQkuwUCad131AAKCRA2KwveOeQk
 u2tAAP9+DZqxGgNeJSvbzovlFaiFev8b78+tZBZ5ini0ygEbYQEApyejML17Lfqc
 fwhu3aXHfwqIcUw5UfOCMHX/WvnY+AE=
 =7l7I
 -----END PGP SIGNATURE-----

Merge tag 'execve-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull execve updates from Kees Cook:

 - use strnlen() in __set_task_comm (Thorsten Blum)

 - update task_struct->comm comment (Thorsten Blum)

* tag 'execve-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  sched: update task_struct->comm comment
  exec: use strnlen() in __set_task_comm
This commit is contained in:
Linus Torvalds 2026-04-13 17:41:36 -07:00
commit 613b48bbd4
2 changed files with 4 additions and 7 deletions

View File

@ -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);

View File

@ -1163,12 +1163,9 @@ struct task_struct {
/*
* executable name, excluding path.
*
* - normally initialized begin_new_exec()
* - set it with set_task_comm()
* - strscpy_pad() to ensure it is always NUL-terminated and
* zero-padded
* - task_lock() to ensure the operation is atomic and the name is
* fully updated.
* - normally initialized by begin_new_exec()
* - set it with set_task_comm() to ensure it is always
* NUL-terminated and zero-padded
*/
char comm[TASK_COMM_LEN];