cgroup: Replace all non-returning strlcpy with strscpy
authorAzeem Shaikh <azeemshaikh38@gmail.com>
Wed, 17 May 2023 14:49:10 +0000 (14:49 +0000)
committerTejun Heo <tj@kernel.org>
Mon, 22 May 2023 19:05:57 +0000 (09:05 -1000)
commitc33080cdc0cab7e72c5e4841cb7533d18a3130dc
tree81287d9edee01139f5e98545e83afcb4ecf837be
parent658888050998d0f0f7d8eca0c4dbb304bfa408bb
cgroup: 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

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup-v1.c