Thread (6 messages) 6 messages, 3 authors, 2025-04-04

Re: [PATCH] tracing: Replace deprecated strncpy() with memcpy() for stack_trace_filter_buf

From: Devaansh Kumar <hidden>
Date: 2025-04-04 12:28:33
Also in: linux-kernel-mentees, lkml

On Fri, 4 Apr 2025 at 01:05, Steven Rostedt [off-list ref] wrote:
On Fri,  4 Apr 2025 00:43:40 +0530
Devaansh Kumar [off-list ref] wrote:
quoted
@@ -537,14 +538,16 @@ stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
      return ret;
 }

-static char stack_trace_filter_buf[COMMAND_LINE_SIZE+1] __initdata;
+static char stack_trace_filter_buf[COMMAND_LINE_SIZE+1] __initdata __nonstring;

 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)
+             memcpy(stack_trace_filter_buf, str + len, sizeof(stack_trace_filter_buf));
Hmm, this location looks like it can just use strscpy().
Yes strscpy() also works. But since stack_trace_filter_buf is length
bounded, shouldn't memcpy be the right choice?

-- Devaansh Kumar
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help