* [PATCH v2] tracing: Replace deprecated strncpy() with strscpy() for stack_trace_filter_buf
@ 2025-04-04 13:31 Devaansh Kumar
2025-04-04 13:46 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Devaansh Kumar @ 2025-04-04 13:31 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers
Cc: Devaansh Kumar, linux-trace-kernel, linux-kernel, skhan,
linux-kernel-mentees
strncpy() is deprecated for NUL-terminated destination buffers and must
be replaced by strscpy().
See issue: https://github.com/KSPP/linux/issues/90
Signed-off-by: Devaansh Kumar <devaanshk840@gmail.com>
---
kernel/trace/trace_stack.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 5a48dba912ea..982b1c88fce2 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -3,6 +3,7 @@
* Copyright (C) 2008 Steven Rostedt <srostedt@redhat.com>
*
*/
+#include <linux/string.h>
#include <linux/sched/task_stack.h>
#include <linux/stacktrace.h>
#include <linux/security.h>
@@ -543,8 +544,10 @@ static __init int enable_stacktrace(char *str)
{
int len;
- if ((len = str_has_prefix(str, "_filter=")))
- strncpy(stack_trace_filter_buf, str + len, COMMAND_LINE_SIZE);
+ len = str_has_prefix(str, "_filter=");
+
+ if (len)
+ strscpy(stack_trace_filter_buf, str + len, sizeof(stack_trace_filter_buf));
stack_tracer_enabled = 1;
return 1;
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tracing: Replace deprecated strncpy() with strscpy() for stack_trace_filter_buf
2025-04-04 13:31 [PATCH v2] tracing: Replace deprecated strncpy() with strscpy() for stack_trace_filter_buf Devaansh Kumar
@ 2025-04-04 13:46 ` Steven Rostedt
2025-04-04 13:57 ` Devaansh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2025-04-04 13:46 UTC (permalink / raw)
To: Devaansh Kumar
Cc: mhiramat, mathieu.desnoyers, linux-trace-kernel, linux-kernel,
skhan, linux-kernel-mentees
On Fri, 4 Apr 2025 19:01:03 +0530
Devaansh Kumar <devaanshk840@gmail.com> wrote:
> strncpy() is deprecated for NUL-terminated destination buffers and must
> be replaced by strscpy().
>
> See issue: https://github.com/KSPP/linux/issues/90
>
> Signed-off-by: Devaansh Kumar <devaanshk840@gmail.com>
> ---
> kernel/trace/trace_stack.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
> index 5a48dba912ea..982b1c88fce2 100644
> --- a/kernel/trace/trace_stack.c
> +++ b/kernel/trace/trace_stack.c
> @@ -3,6 +3,7 @@
> * Copyright (C) 2008 Steven Rostedt <srostedt@redhat.com>
> *
> */
> +#include <linux/string.h>
> #include <linux/sched/task_stack.h>
> #include <linux/stacktrace.h>
> #include <linux/security.h>
Is string.h really needed here? And if so, please keep the upside-down
x-mas tree format:
#include <linux/sched/task_stack.h>
#include <linux/stacktrace.h>
#include <linux/security.h>
#include <linux/kallsyms.h>
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/ftrace.h>
#include <linux/module.h>
#include <linux/sysctl.h>
#include <linux/init.h>
The includes *are* ordered.
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tracing: Replace deprecated strncpy() with strscpy() for stack_trace_filter_buf
2025-04-04 13:46 ` Steven Rostedt
@ 2025-04-04 13:57 ` Devaansh Kumar
0 siblings, 0 replies; 3+ messages in thread
From: Devaansh Kumar @ 2025-04-04 13:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: mhiramat, mathieu.desnoyers, linux-trace-kernel, linux-kernel,
skhan, linux-kernel-mentees
On Fri, 4 Apr 2025 at 19:15, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> Is string.h really needed here? And if so, please keep the upside-down
> x-mas tree format:
My bad. It was auto added by my IDE. It is not needed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-04 13:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04 13:31 [PATCH v2] tracing: Replace deprecated strncpy() with strscpy() for stack_trace_filter_buf Devaansh Kumar
2025-04-04 13:46 ` Steven Rostedt
2025-04-04 13:57 ` Devaansh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox