Skip to content

Commit 3cb6cb9

Browse files
neosys007gregkh
authored andcommitted
tracing: Rebuild full_name on each hist_field_name() call
[ Upstream commit 5ec1d1e ] 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: 067fe03 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d20595b commit 3cb6cb9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

kernel/trace/trace_events_hist.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,12 +1342,14 @@ static const char *hist_field_name(struct hist_field *field,
13421342
field->flags & HIST_FIELD_FL_VAR_REF) {
13431343
if (field->system) {
13441344
static char full_name[MAX_FILTER_STR_VAL];
1345+
int len;
1346+
1347+
len = snprintf(full_name, sizeof(full_name), "%s.%s.%s",
1348+
field->system, field->event_name,
1349+
field->name);
1350+
if (len >= sizeof(full_name))
1351+
return NULL;
13451352

1346-
strcat(full_name, field->system);
1347-
strcat(full_name, ".");
1348-
strcat(full_name, field->event_name);
1349-
strcat(full_name, ".");
1350-
strcat(full_name, field->name);
13511353
field_name = full_name;
13521354
} else
13531355
field_name = field->name;

0 commit comments

Comments
 (0)