From: Steven Rostedt <rostedt@goodmis.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org, Kees Cook <kees@kernel.org>
Subject: Re: [PATCH] tracing: replace multiple deprecated strncpy with strscpy
Date: Fri, 11 Oct 2024 19:30:47 -0400 [thread overview]
Message-ID: <20241011193047.0b788145@gandalf.local.home> (raw)
In-Reply-To: <CAFhGd8pGaMxXpsk5gMS98223FW5wq-vQPyt1srVCrP_Fg6Ex9g@mail.gmail.com>
On Fri, 11 Oct 2024 14:59:16 -0700
Justin Stitt <justinstitt@google.com> wrote:
> So, assuming I haven't lost your faith, I can send a v2 along the lines of:
Not yet ;-)
>
> 1)
> strscpy(num_buf, str + s, len + 1);
>
> ... or
> 2)
> memcpy(num_buf, str + s, len);
> num_buf[len] = 0;
>
> And if you're wondering about option 3: "Don't change anything because
> the code works". I'd reiterate that I think it's important to replace
> bad ambiguous APIs. There are many cases where folks use strncpy() as
> a glorified memcpy because they want the padding behavior, or they use
> it on non-null terminated destinations or tons of other "misuses".
> Ambiguous code like that poses a real danger to the maintainability of
> the codebase and opens threat vectors.
I use it as a string memcpy, where it doesn't copy more than source. But I
don't care about the padding. So option 2 is fine with me.
-- Steve
prev parent reply other threads:[~2024-10-11 23:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 0:03 [PATCH] tracing: replace multiple deprecated strncpy with strscpy Justin Stitt
2024-10-09 1:12 ` Steven Rostedt
2024-10-11 21:59 ` Justin Stitt
2024-10-11 23:30 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241011193047.0b788145@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox