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: Tue, 8 Oct 2024 21:12:57 -0400 [thread overview]
Message-ID: <20241008211257.6c9c9f88@rorschach.local.home> (raw)
In-Reply-To: <20240930-strncpy-kernel-trace-trace_events_filter-c-v1-1-feed30820b83@google.com>
On Mon, 30 Sep 2024 17:03:45 -0700
Justin Stitt <justinstitt@google.com> wrote:
> strncpy() is deprecated for use on NUL-terminated destination strings [1] and
> as such we should prefer more robust and less ambiguous string interfaces.
>
> We expect the @pattern and @num_buf strings to be NUL-terminated, as
> evidenced by their manual NUL-byte assignments immediately following
> each copy.
>
> Switch to using strscpy which guarantees NUL-termination for the
> destination buffer -- eschewing manual NUL-byte assignments. strscpy
> does not NUL-pad so to keep this behavior zero-allocate @num_buf. @pred
> is already zero-allocated before the copies.
> pred = kzalloc(sizeof(*pred), GFP_KERNEL);
>
> This should result in no behavioral changes whilst helping towards the
> goal of [2] -- with the ultimate goal of removing strncpy in favor of
> less ambiguous and more robust alternatives.
>
> 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 [2]
> Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
> Cc: Kees Cook <keescook@chromium.org>
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Justin Stitt <justinstitt@google.com>
So this breaks my tests. This is why I have trouble with taking changes
like this :-(
Before this patch, his worked:
# echo 'common_pid != 0 && common_pid != 120 && common_pid != 1253 && common_pid != 17 && common_pid != 394 && common_pid != 81 && common_pid != 87' > /sys/kernel/tracing/events/sched/sched_switch/filter
But now it gives an error of:
-bash: echo: write error: Invalid argument
I have to drop this.
-- Steve
next prev parent reply other threads:[~2024-10-09 1:13 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 [this message]
2024-10-11 21:59 ` Justin Stitt
2024-10-11 23:30 ` Steven Rostedt
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=20241008211257.6c9c9f88@rorschach.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