Thread (5 messages) 5 messages, 5 authors, 2025-02-14

Re: [PATCH linux-next] tracing: use strscpy() to instead of strncpy()

From: Thorsten Blum <hidden>
Date: 2025-02-14 22:27:25
Also in: linux-hardening, lkml

Hi Steven,

I was about to submit the same patch when I found this one from 2023.

On 24. Jan 2023, at 18:17, Steven Rostedt wrote:
So the above will *always* return -E2BIG *and* not end buf[] with '\0' as
if strscpy() returns -E2BIG, then buf[] is not guaranteed to be
NUL-terminated.
The return value is not used and the strscpy() documentation in
linux/string.h says:

"The destination @dst buffer is always NUL terminated, unless it's zero-
sized." and "Preferred to strncpy() since it always returns a valid
string, ..."

Has strscpy() changed since 2023 or could this patch be revisited? I saw
that Justin also made an effort in September 2024 [1] to revisit it and
to remove the deprecated strncpy() here.
NACK!

-- Steve
Thanks,
Thorsten

[1] https://lore.kernel.org/r/yhv3rzg6vhgwage27cyvg72t4vwf5x3tdtj3zjipryzvz3u55x@c33q753uxyi3/ (local)
Cc: linux-hardening@vger.kernel.org
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help