tracing: Updates for 6.15
Subsystems (2)
Steven Rostedt
maintainercover 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(-)
Steven Rostedt
maintainerPATCH 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.
--- kernel/trace/trace_events_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
@@ -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
Steven Rostedt
maintainerPATCH 2/2 tracing: Replace strncpy with memcpy for fixed-length substring copy
In reply to Steven RostedtFrom: 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
@@ -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