Skip to contentSkip to conversation

tracing: Updates for 6.15

PATCH New Steven Rostedt 1 participant 3 messages Mar 27, 2025

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Updates for 6.15

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(-)
author maintainer
#1 lore raw

PATCH 1/2 tracing: Fix synth event printk format for str fields

From: Douglas Raillard <[email protected]>

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 Masami Hiramatsu <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Fixes 8db4d6bfbbf92 ("tracing: Change synthetic event string format to limit printed length")
---
 kernel/trace/trace_events_synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
index a5c5f34c207a..6d592cbc38e4 100644
@@ -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";
 
Signature · 1 line
2.47.2
author maintainer
#2 lore raw

PATCH 2/2 tracing: Replace strncpy with memcpy for fixed-length substring copy

In reply to Steven Rostedt

From: Siddarth G <[email protected]>

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.

---
 kernel/trace/trace_events_synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
index 6d592cbc38e4..969f48742d72 100644
@@ -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);
Signature · 1 line
2.47.2