perf: Replace strlcpy with strscpy
authorAzeem Shaikh <azeemshaikh38@gmail.com>
Mon, 3 Jul 2023 16:58:16 +0000 (16:58 +0000)
committerKees Cook <keescook@chromium.org>
Thu, 27 Jul 2023 15:51:25 +0000 (08:51 -0700)
commitc9732f1461f947429f8ee9289792c5ffea793350
tree298c5375e0e7704a66104dc4fdaa90d06544d816
parent61ce78f29a694772c3b2c5c749589682dbdfec2d
perf: Replace 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

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230703165817.2840457-1-azeemshaikh38@gmail.com
Signed-off-by: Kees Cook <keescook@chromium.org>
kernel/events/core.c