* [PATCH v2] tracing: Replace strncpy() with strscpy() when copying comm
@ 2024-10-31 12:01 Jinjie Ruan
2024-10-31 15:12 ` Mathieu Desnoyers
0 siblings, 1 reply; 4+ messages in thread
From: Jinjie Ruan @ 2024-10-31 12:01 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, linux-kernel,
linux-trace-kernel
Cc: ruanjinjie
Replace the depreciated[1] strncpy() calls with strscpy()
when copying comm.
Link: https://github.com/KSPP/linux/issues/90 [1]
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- Fix the trace_events_hist.c build problem.
---
kernel/trace/trace.c | 2 +-
kernel/trace/trace_events_hist.c | 4 ++--
kernel/trace/trace_sched_switch.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a8f52b6527ca..cb2c66554212 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1934,7 +1934,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
max_data->critical_start = data->critical_start;
max_data->critical_end = data->critical_end;
- strncpy(max_data->comm, tsk->comm, TASK_COMM_LEN);
+ strscpy(max_data->comm, tsk->comm);
max_data->pid = tsk->pid;
/*
* If tsk == current, then use current_uid(), as that does not use
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 5f9119eb7c67..8e370bc4faa4 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1599,7 +1599,7 @@ static inline void save_comm(char *comm, struct task_struct *task)
return;
}
- strncpy(comm, task->comm, TASK_COMM_LEN);
+ strscpy(comm, task->comm, TASK_COMM_LEN);
}
static void hist_elt_data_free(struct hist_elt_data *elt_data)
@@ -3405,7 +3405,7 @@ static bool cond_snapshot_update(struct trace_array *tr, void *cond_data)
elt_data = context->elt->private_data;
track_elt_data = track_data->elt.private_data;
if (elt_data->comm)
- strncpy(track_elt_data->comm, elt_data->comm, TASK_COMM_LEN);
+ strscpy(track_elt_data->comm, elt_data->comm, TASK_COMM_LEN);
track_data->updated = true;
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index 8a407adb0e1c..573b5d8e8a28 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.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] tracing: Replace strncpy() with strscpy() when copying comm
2024-10-31 12:01 [PATCH v2] tracing: Replace strncpy() with strscpy() when copying comm Jinjie Ruan
@ 2024-10-31 15:12 ` Mathieu Desnoyers
2024-10-31 15:48 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Desnoyers @ 2024-10-31 15:12 UTC (permalink / raw)
To: Jinjie Ruan, rostedt, mhiramat, linux-kernel, linux-trace-kernel
On 2024-10-31 08:01, Jinjie Ruan wrote:
> Replace the depreciated[1] strncpy() calls with strscpy()
> when copying comm.
>
> Link: https://github.com/KSPP/linux/issues/90 [1]
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v2:
> - Fix the trace_events_hist.c build problem.
> ---
> kernel/trace/trace.c | 2 +-
> kernel/trace/trace_events_hist.c | 4 ++--
> kernel/trace/trace_sched_switch.c | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index a8f52b6527ca..cb2c66554212 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1934,7 +1934,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
> max_data->critical_start = data->critical_start;
> max_data->critical_end = data->critical_end;
>
> - strncpy(max_data->comm, tsk->comm, TASK_COMM_LEN);
> + strscpy(max_data->comm, tsk->comm);
make allyesconfig + make please ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tracing: Replace strncpy() with strscpy() when copying comm
2024-10-31 15:12 ` Mathieu Desnoyers
@ 2024-10-31 15:48 ` Steven Rostedt
2024-11-01 1:45 ` Jinjie Ruan
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2024-10-31 15:48 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: Jinjie Ruan, mhiramat, linux-kernel, linux-trace-kernel
On Thu, 31 Oct 2024 11:12:06 -0400
Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -1934,7 +1934,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
> > max_data->critical_start = data->critical_start;
> > max_data->critical_end = data->critical_end;
> >
> > - strncpy(max_data->comm, tsk->comm, TASK_COMM_LEN);
> > + strscpy(max_data->comm, tsk->comm);
>
> make allyesconfig + make please ?
Or at a minimum, make sure all the code you change is compiled.
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tracing: Replace strncpy() with strscpy() when copying comm
2024-10-31 15:48 ` Steven Rostedt
@ 2024-11-01 1:45 ` Jinjie Ruan
0 siblings, 0 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-11-01 1:45 UTC (permalink / raw)
To: Steven Rostedt, Mathieu Desnoyers
Cc: mhiramat, linux-kernel, linux-trace-kernel
On 2024/10/31 23:48, Steven Rostedt wrote:
> On Thu, 31 Oct 2024 11:12:06 -0400
> Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>
>>> --- a/kernel/trace/trace.c
>>> +++ b/kernel/trace/trace.c
>>> @@ -1934,7 +1934,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
>>> max_data->critical_start = data->critical_start;
>>> max_data->critical_end = data->critical_end;
>>>
>>> - strncpy(max_data->comm, tsk->comm, TASK_COMM_LEN);
>>> + strscpy(max_data->comm, tsk->comm);
>>
>> make allyesconfig + make please ?
>
> Or at a minimum, make sure all the code you change is compiled.
Sure, x86 and arm64 allmodconfig is ok
Thank you!
>
> -- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-01 1:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31 12:01 [PATCH v2] tracing: Replace strncpy() with strscpy() when copying comm Jinjie Ruan
2024-10-31 15:12 ` Mathieu Desnoyers
2024-10-31 15:48 ` Steven Rostedt
2024-11-01 1:45 ` Jinjie Ruan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox