public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH 1/2] exec: use strnlen() in __set_task_comm
@ 2026-04-01 15:20 Thorsten Blum
  2026-04-01 16:30 ` Jan Kara
  2026-04-01 19:28 ` Kees Cook
  0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-04-01 15:20 UTC (permalink / raw)
  To: Kees Cook, Alexander Viro, Christian Brauner, Jan Kara
  Cc: Thorsten Blum, linux-mm, linux-fsdevel, linux-kernel

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

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 fs/exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-01 19:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 15:20 [PATCH 1/2] exec: use strnlen() in __set_task_comm Thorsten Blum
2026-04-01 16:30 ` Jan Kara
2026-04-01 19:28 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox