Skip to content

Commit 5248f40

Browse files
JustinStittkees
authored andcommitted
binfmt: replace deprecated strncpy
strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. There is a _nearly_ identical implementation of fill_psinfo present in binfmt_elf.c -- except that one uses get_task_comm over strncpy(). Let's mirror that in binfmt_elf_fdpic.c Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: KSPP#90 Cc: <[email protected]> Signed-off-by: Justin Stitt <[email protected]> Link: https://lore.kernel.org/r/20240321-strncpy-fs-binfmt_elf_fdpic-c-v2-1-0b6daec6cc56@google.com Signed-off-by: Kees Cook <[email protected]>
1 parent 2aea94a commit 5248f40

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/binfmt_elf_fdpic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
13591359
SET_UID(psinfo->pr_uid, from_kuid_munged(cred->user_ns, cred->uid));
13601360
SET_GID(psinfo->pr_gid, from_kgid_munged(cred->user_ns, cred->gid));
13611361
rcu_read_unlock();
1362-
strncpy(psinfo->pr_fname, p->comm, sizeof(psinfo->pr_fname));
1362+
get_task_comm(psinfo->pr_fname, p);
13631363

13641364
return 0;
13651365
}

0 commit comments

Comments
 (0)