From: Steven Rostedt <rostedt@goodmis.org>
To: Daniel Yang <danielyangkang@gmail.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org (open list:TRACING),
linux-trace-kernel@vger.kernel.org (open list:TRACING)
Subject: Re: [PATCH] set_cmdline: replace fragile/deprecated strncpy with strscpy
Date: Tue, 12 Nov 2024 16:12:48 -0500 [thread overview]
Message-ID: <20241112161248.0fbdc802@gandalf.local.home> (raw)
In-Reply-To: <20241105072007.426782-1-danielyangkang@gmail.com>
On Mon, 4 Nov 2024 23:20:07 -0800
Daniel Yang <danielyangkang@gmail.com> wrote:
> Kernel docs identify strncpy as being fragile and ambiguous. Replaced
> strncpy with strscpy so dest str is null terminated and not padded.
>
Already been updated:
https://lore.kernel.org/linux-trace-kernel/20241031120139.1343025-1-ruanjinjie@huawei.com/
-- Steve
> Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
> ---
> kernel/trace/trace_sched_switch.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
> index 8a407adb0..573b5d8e8 100644
> --- a/kernel/trace/trace_sched_switch.c
> +++ b/kernel/trace/trace_sched_switch.c
> @@ -187,7 +187,7 @@ static inline char *get_saved_cmdlines(int idx)
>
> static inline void set_cmdline(int idx, const char *cmdline)
> {
> - strncpy(get_saved_cmdlines(idx), cmdline, TASK_COMM_LEN);
> + strscpy(get_saved_cmdlines(idx), cmdline, TASK_COMM_LEN);
> }
>
> static void free_saved_cmdlines_buffer(struct saved_cmdlines_buffer *s)
prev parent reply other threads:[~2024-11-12 21:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 7:20 [PATCH] set_cmdline: replace fragile/deprecated strncpy with strscpy Daniel Yang
2024-11-12 21:12 ` 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=20241112161248.0fbdc802@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=danielyangkang@gmail.com \
--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