summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-04-14 03:41:36 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2026-04-14 03:41:36 +0300
commit613b48bbd465941f796c174c96707a9bce595265 (patch)
tree99f4e9a291513b61c88eaf0ab99ca438e865385b
parentcae0d23288e959a05377a307b96dc30ea4fd9f1a (diff)
parent9bf092c97b86af63694d9902b9e14047214ba76d (diff)
downloadlinux-613b48bbd465941f796c174c96707a9bce595265.tar.xz
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
-rw-r--r--fs/exec.c2
-rw-r--r--include/linux/sched.h9
2 files changed, 4 insertions, 7 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 9ea3a775d51e..ba12b4c466f6 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -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);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ffb2ad9716f0..54820a427014 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -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];