summaryrefslogtreecommitdiff
path: root/arch/nios2/kernel/cpuinfo.c
diff options
context:
space:
mode:
authorAzeem Shaikh <azeemshaikh38@gmail.com>2023-05-30 16:23:58 +0000
committerDinh Nguyen <dinguyen@kernel.org>2023-06-13 16:51:49 -0500
commit6a22e017f952ecaf4bb510cd0939259470a27b06 (patch)
tree3cbfcd647a46bae5838e0213783e4a844d6f77c5 /arch/nios2/kernel/cpuinfo.c
parent6ebe94baa2b9ddf3ccbb7f94df6ab26234532734 (diff)
nios2: Replace all non-returning strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] https://github.com/KSPP/linux/issues/89 Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Diffstat (limited to 'arch/nios2/kernel/cpuinfo.c')
-rw-r--r--arch/nios2/kernel/cpuinfo.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c
index 203870c4b86d..338849c430a5 100644
--- a/arch/nios2/kernel/cpuinfo.c
+++ b/arch/nios2/kernel/cpuinfo.c
@@ -47,7 +47,7 @@ void __init setup_cpuinfo(void)
str = of_get_property(cpu, "altr,implementation", &len);
if (str)
- strlcpy(cpuinfo.cpu_impl, str, sizeof(cpuinfo.cpu_impl));
+ strscpy(cpuinfo.cpu_impl, str, sizeof(cpuinfo.cpu_impl));
else
strcpy(cpuinfo.cpu_impl, "<unknown>");