Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Rebuild full_name on each hist_field_name() call

hist_field_name() uses a static MAX_FILTER_STR_VAL buffer for fully
qualified variable-reference names, but it currently appends into that
buffer with strcat() without rebuilding it first. As a result, repeated
calls append a new "system.event.field" name onto the previous one,
which can eventually run past the end of full_name.

Build the name with snprintf() on each call and return NULL if the fully
qualified name does not fit in MAX_FILTER_STR_VAL.

Link: https://patch.msgid.link/20260401112224.85582-1-pengpeng@iscas.ac.cn
Fixes: 067fe038e70f ("tracing: Add variable reference handling to hist triggers")
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Tested-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Pengpeng Hou and committed by
Steven Rostedt (Google)
5ec1d1e9 0ec6be95

+7 -5
+7 -5
kernel/trace/trace_events_hist.c
··· 1361 1361 field->flags & HIST_FIELD_FL_VAR_REF) { 1362 1362 if (field->system) { 1363 1363 static char full_name[MAX_FILTER_STR_VAL]; 1364 + int len; 1364 1365 1365 - strcat(full_name, field->system); 1366 - strcat(full_name, "."); 1367 - strcat(full_name, field->event_name); 1368 - strcat(full_name, "."); 1369 - strcat(full_name, field->name); 1366 + len = snprintf(full_name, sizeof(full_name), "%s.%s.%s", 1367 + field->system, field->event_name, 1368 + field->name); 1369 + if (len >= sizeof(full_name)) 1370 + return NULL; 1371 + 1370 1372 field_name = full_name; 1371 1373 } else 1372 1374 field_name = field->name;