linux/arch/um/os-Linux
Justin Stitt e0bbf92682 um,ethertap: Replace deprecated strncpy() with strscpy()
`strncpy` is deprecated for use on NUL-terminated destination strings [1].

`gate_buf` should always be NUL-terminated and does not require
NUL-padding. It is used as a string arg inside an argv array given to
`run_helper()`. Due to this, let's use `strscpy` as it guarantees
NUL-terminated on the destination buffer preventing potential buffer
overreads [2].

This exact invocation was changed from `strcpy` to `strncpy` in commit
7879b1d94b ("um,ethertap: use strncpy") back in 2015. Let's continue
hardening our `str*cpy` apis and use the newer and safer `strscpy`!

Link: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings[1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230911-strncpy-arch-um-os-linux-drivers-ethertap_user-c-v1-1-d9e53f52ab32@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
2023-09-29 11:37:50 -07:00
..
drivers um,ethertap: Replace deprecated strncpy() with strscpy() 2023-09-29 11:37:50 -07:00
skas um: make stub data pages size tweakable 2023-04-20 23:08:43 +02:00
elf_aux.c ELF: fix all "Elf" typos 2023-04-08 13:45:37 -07:00
execvp.c
file.c
helper.c
irq.c um: Remove the unneeded result variable 2023-02-01 22:11:24 +01:00
main.c
Makefile kbuild: remove --include-dir MAKEFLAG from top Makefile 2023-02-05 18:51:22 +09:00
mem.c
process.c
registers.c
sigio.c Revert "um: Use swap() to make code cleaner" 2023-07-27 13:07:03 -07:00
signal.c
start_up.c
time.c
tty.c
umid.c um: Remove strlcpy declaration 2023-07-27 08:51:06 -07:00
user_syms.c Revert "[PATCH] uml: export symbols added by GCC hardened" 2023-06-15 04:47:04 +09:00
util.c um: seed rng using host OS rng 2022-07-18 15:04:04 +02:00