mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [for-next][PATCH 0/2] tracing: Updates for 6.15
@ 2025-03-27  0:08 Steven Rostedt
  2025-03-27  0:08 ` [for-next][PATCH 1/2] tracing: Fix synth event printk format for str fields Steven Rostedt
  2025-03-27  0:08 ` [for-next][PATCH 2/2] tracing: Replace strncpy with memcpy for fixed-length substring copy Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-03-27  0:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton

  git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next

Head SHA1: e0344f9564f5847dc20e245fbea67a4b262ee659


Douglas Raillard (1):
      tracing: Fix synth event printk format for str fields

Siddarth G (1):
      tracing: Replace strncpy with memcpy for fixed-length substring copy

----
 kernel/trace/trace_events_synth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [for-next][PATCH 1/2] tracing: Fix synth event printk format for str fields
  2025-03-27  0:08 [for-next][PATCH 0/2] tracing: Updates for 6.15 Steven Rostedt
@ 2025-03-27  0:08 ` Steven Rostedt
  2025-03-27  0:08 ` [for-next][PATCH 2/2] tracing: Replace strncpy with memcpy for fixed-length substring copy Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-03-27  0:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
	stable, Douglas Raillard

From: Douglas Raillard <douglas.raillard@arm.com>

The printk format for synth event uses "%.*s" to print string fields,
but then only passes the pointer part as var arg.

Replace %.*s with %s as the C string is guaranteed to be null-terminated.

The output in print fmt should never have been updated as __get_str()
handles the string limit because it can access the length of the string in
the string meta data that is saved in the ring buffer.

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fixes: 8db4d6bfbbf92 ("tracing: Change synthetic event string format to limit printed length")
Link: https://lore.kernel.org/20250325165202.541088-1-douglas.raillard@arm.com
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index a5c5f34c207a..6d592cbc38e4 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -305,7 +305,7 @@ static const char *synth_field_fmt(char *type)
 	else if (strcmp(type, "gfp_t") == 0)
 		fmt = "%x";
 	else if (synth_field_is_string(type))
-		fmt = "%.*s";
+		fmt = "%s";
 	else if (synth_field_is_stack(type))
 		fmt = "%s";
 
-- 
2.47.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [for-next][PATCH 2/2] tracing: Replace strncpy with memcpy for fixed-length substring copy
  2025-03-27  0:08 [for-next][PATCH 0/2] tracing: Updates for 6.15 Steven Rostedt
  2025-03-27  0:08 ` [for-next][PATCH 1/2] tracing: Fix synth event printk format for str fields Steven Rostedt
@ 2025-03-27  0:08 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-03-27  0:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
	Siddarth G

From: Siddarth G <siddarthsgml@gmail.com>

checkpatch.pl reports the following warning:
WARNING: Prefer strscpy, strscpy_pad, or __nonstring over strncpy
(see: https://github.com/KSPP/linux/issues/90)

In synth_field_string_size(), replace strncpy() with memcpy() to copy 'len'
characters from 'start' to 'buf'. The code manually adds a NUL terminator
after the copy, making memcpy safe here.

Link: https://lore.kernel.org/20250325181232.38284-1-siddarthsgml@gmail.com
Signed-off-by: Siddarth G <siddarthsgml@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 6d592cbc38e4..969f48742d72 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -207,7 +207,7 @@ static int synth_field_string_size(char *type)
 	if (len == 0)
 		return 0; /* variable-length string */
 
-	strncpy(buf, start, len);
+	memcpy(buf, start, len);
 	buf[len] = '\0';
 
 	err = kstrtouint(buf, 0, &size);
-- 
2.47.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-27  0:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-27  0:08 [for-next][PATCH 0/2] tracing: Updates for 6.15 Steven Rostedt
2025-03-27  0:08 ` [for-next][PATCH 1/2] tracing: Fix synth event printk format for str fields Steven Rostedt
2025-03-27  0:08 ` [for-next][PATCH 2/2] tracing: Replace strncpy with memcpy for fixed-length substring copy Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®