* [PATCH] set_cmdline: replace fragile/deprecated strncpy with strscpy
@ 2024-11-05 7:20 Daniel Yang
2024-11-12 21:12 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Yang @ 2024-11-05 7:20 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
open list:TRACING, open list:TRACING
Cc: Daniel Yang
Kernel docs identify strncpy as being fragile and ambiguous. Replaced
strncpy with strscpy so dest str is null terminated and not padded.
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)
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] set_cmdline: replace fragile/deprecated strncpy with strscpy
2024-11-05 7:20 [PATCH] set_cmdline: replace fragile/deprecated strncpy with strscpy Daniel Yang
@ 2024-11-12 21:12 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2024-11-12 21:12 UTC (permalink / raw)
To: Daniel Yang
Cc: Masami Hiramatsu, Mathieu Desnoyers, open list:TRACING,
open list:TRACING
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-12 21:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05 7:20 [PATCH] set_cmdline: replace fragile/deprecated strncpy with strscpy Daniel Yang
2024-11-12 21:12 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox