]> Git Repo - J-linux.git/commitdiff
binfmt: replace deprecated strncpy
authorJustin Stitt <[email protected]>
Thu, 21 Mar 2024 20:04:08 +0000 (20:04 +0000)
committerKees Cook <[email protected]>
Fri, 22 Mar 2024 03:20:52 +0000 (20:20 -0700)
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
Link: https://github.com/KSPP/linux/issues/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]>
fs/binfmt_elf_fdpic.c

index 1920ed69279b5805f21ba66772dd661b6e3042e8..3314249e867474ff81075b4e007030caaf0fcd2e 100644 (file)
@@ -1359,7 +1359,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
        SET_UID(psinfo->pr_uid, from_kuid_munged(cred->user_ns, cred->uid));
        SET_GID(psinfo->pr_gid, from_kgid_munged(cred->user_ns, cred->gid));
        rcu_read_unlock();
-       strncpy(psinfo->pr_fname, p->comm, sizeof(psinfo->pr_fname));
+       get_task_comm(psinfo->pr_fname, p);
 
        return 0;
 }
This page took 0.050402 seconds and 4 git commands to generate.