public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tracing/hist: bound full field-name construction
@ 2026-03-29  3:09 Pengpeng Hou
  2026-03-29 18:39 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Pengpeng Hou @ 2026-03-29  3:09 UTC (permalink / raw)
  To: rostedt, mhiramat, mathieu.desnoyers, tom.zanussi
  Cc: linux-kernel, linux-trace-kernel, pengpeng

hist_field_name() builds a fully qualified synthetic field name in a
fixed MAX_FILTER_STR_VAL buffer using repeated strcat() calls. Long
system, event, and field names can therefore overflow the static staging
buffer.

Build the qualified name with snprintf() and fall back to the plain
field name if it does not fit.

Fixes: 067fe038e70f ("tracing: Add variable reference handling to hist triggers")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 kernel/trace/trace_events_hist.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 73ea180cad55..4a27da628a71 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1362,12 +1362,12 @@ static const char *hist_field_name(struct hist_field *field,
 		if (field->system) {
 			static char full_name[MAX_FILTER_STR_VAL];
 
-			strcat(full_name, field->system);
-			strcat(full_name, ".");
-			strcat(full_name, field->event_name);
-			strcat(full_name, ".");
-			strcat(full_name, field->name);
-			field_name = full_name;
+			if (snprintf(full_name, sizeof(full_name), "%s.%s.%s",
+				     field->system, field->event_name,
+				     field->name) < sizeof(full_name))
+				field_name = full_name;
+			else
+				field_name = field->name;
 		} else
 			field_name = field->name;
 	} else if (field->flags & HIST_FIELD_FL_TIMESTAMP)
-- 
2.50.1 (Apple Git-155)


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

end of thread, other threads:[~2026-04-13 22:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-29  3:09 [PATCH 1/2] tracing/hist: bound full field-name construction Pengpeng Hou
2026-03-29 18:39 ` Steven Rostedt
2026-03-30  2:46 ` [PATCH v2 1/2] tracing/hist: rebuild full_name on each hist_field_name() call Pengpeng Hou
2026-03-30 14:22   ` Steven Rostedt
2026-04-01 11:22 ` Pengpeng Hou
2026-04-08  1:05   ` Steven Rostedt
2026-04-08 15:58     ` Tom Zanussi
2026-04-08 16:25       ` Steven Rostedt
2026-04-08 17:18         ` Tom Zanussi
2026-04-08  2:15   ` Pengpeng Hou
2026-04-08  2:14     ` Steven Rostedt
2026-04-13 22:38   ` Tom Zanussi

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