Skip to contentSkip to conversation

fs-exec-replace-strncpy-with-strscpy_pad-in-__get_task_comm.patch removed from -mm tree

merged [email protected] 1 participant 1 message Jan 20, 2022

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: fs/exec: replace strncpy with strscpy_pad in __get_task_comm
has been removed from the -mm tree. Its filename was
fs-exec-replace-strncpy-with-strscpy_pad-in-__get_task_comm.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Yafang Shao <[email protected]>
Subject: fs/exec: replace strncpy with strscpy_pad in __get_task_comm

If the dest buffer size is smaller than sizeof(tsk->comm), the buffer will be without null ternimator, that may cause problem. Using strscpy_pad() instead of strncpy() in __get_task_comm() can make the string always nul ternimated and zero padded.

Cc Mathieu Desnoyers <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Michal Miroslaw <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Al Viro <[email protected]>
Cc Kees Cook <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Dennis Dalessandro <[email protected]>

---

 fs/exec.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/exec.c renamed from fs/exec.c~fs-exec-replace-strncpy-with-strscpy_pad-in-__get_task_comm +2 -1
@@ -1207,7 +1207,8 @@ static int unshare_sighand(struct task_s
 char *__get_task_comm(char *buf, size_t buf_size, struct task_struct *tsk)
 {
 	task_lock(tsk);
-	strncpy(buf, tsk->comm, buf_size);
+	/* Always NUL terminated and zero-padded */
+	strscpy_pad(buf, tsk->comm, buf_size);
 	task_unlock(tsk);
 	return buf;
 }

_

Patches currently in -mm which might be from [email protected] are