tracing/histogram: Don't use strlen to find length of stacktrace variables
authorTom Zanussi <zanussi@kernel.org>
Fri, 10 Feb 2023 21:33:03 +0000 (15:33 -0600)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Thu, 16 Feb 2023 00:59:09 +0000 (19:59 -0500)
commitfc1a9dc101292403babe0c5c2f99f4748580ed98
tree0483ad668866fb6f5d2f58690b1d08733153afe7
parent9c1c251d670bc107b9ce600a2c20adb08b4849e9
tracing/histogram: Don't use strlen to find length of stacktrace variables

Because stacktraces are saved in dynamic strings,
trace_event_raw_event_synth() uses strlen to determine the length of
the stack.  Stacktraces may contain 0-bytes, though, in the saved
addresses, so the length found and passed to reserve() will be too
small.

Fix this by using the first unsigned long in the stack variables to
store the actual number of elements in the stack and have
trace_event_raw_event_synth() use that to determine the length of the
stack.

Link: https://lkml.kernel.org/r/1ed6906cd9d6477ef2bd8e63c61de20a9ffe64d7.1676063532.git.zanussi@kernel.org
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c
kernel/trace/trace_events_synth.c