summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@engflow.com>2024-11-03 20:48:16 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-05 14:02:24 +0100
commit660ea0db314df4dcdf2f6ff438e908f7d8b844f5 (patch)
treecc31a2350377e1423b1f2de55d2c3d44f3b9dac3
parentbbe48e47b978558a58ddec8888e217a74dfbc14c (diff)
downloadlinux-660ea0db314df4dcdf2f6ff438e908f7d8b844f5.tar.gz
linux-660ea0db314df4dcdf2f6ff438e908f7d8b844f5.tar.bz2
linux-660ea0db314df4dcdf2f6ff438e908f7d8b844f5.zip
perf trace: avoid garbage when not printing a trace event's arguments
[ Upstream commit 5fb8e56542a3cf469fdf25d77f50e21cbff3ae7e ] trace__fprintf_tp_fields may not print any tracepoint arguments. E.g., if the argument values are all zero. Previously, this would result in a totally uninitialized buffer being passed to fprintf, which could lead to garbage on the console. Fix the problem by passing the number of initialized bytes fprintf. Fixes: f11b2803bb88 ("perf trace: Allow choosing how to augment the tracepoint arguments") Signed-off-by: Benjamin Peterson <benjamin@engflow.com> Tested-by: Howard Chu <howardchu95@gmail.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Link: https://lore.kernel.org/r/20241103204816.7834-1-benjamin@engflow.com Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--tools/perf/builtin-trace.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4cc942f7fec7..4f47fe3b211d 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -3087,7 +3087,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
}
- return printed + fprintf(trace->output, "%s", bf);
+ return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
}
static int trace__event_handler(struct trace *trace, struct evsel *evsel,