Re: [PATCH v4] arm64/sysreg: refactor deprecated strncpy

From
Will Deacon <will@kernel.org>
Date
2023-09-08 10:29:03
Also in
linux-hardening, lkml
Reply to
Justin Stitt, 2023-09-07
On Thu, Sep 07, 2023 at 11:17:08AM -0700, Justin Stitt wrote:
On Thu, Sep 7, 2023 at 10:37 AM Konrad Dybcio [off-list ref] wrote:
quoted


On 5.09.2023 22:10, Justin Stitt wrote:
quoted
strncpy is deprecated [1] and should not be used if the src string is
not NUL-terminated.

When dealing with `cmdline` we are counting the number of characters
until a space then copying these over into `buf`. Let's not use any of
the str*() functions since the src string is not necessarily NUL-terminated.

Prefer `memcpy()` alongside a forced NUL-termination as it more
accurately describes what is going on within this function, i.e: copying
from non NUL-terminated buffer into a NUL-terminated buffer.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://github.com/KSPP/linux/issues/90
Cc: <redacted>
Suggested-by: Kees Cook <redacted>
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
Hi,

some form of this patch [1] went into -next and it broke booting
on at least the Qualcomm SC8280XP-based Lenovo Thinkpad X13S.
Thanks for the heads up! The previous versions of the patch (including
the one that was applied) had some errors. This patch should be good
and Will is looking to apply it to arm64 fixes tree.
Yes, it should be fixed in linux-next 20230908.

Cheers,

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (6 messages) 6 messages, 3 authors, last reply 2023-09-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help