Commit 50a3242d authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt (Google)

tracing: Fix trace_check_vprintf() when tp_printk is used

When the tp_printk kernel command line is used, the trace events go
directly to printk(). It is still checked via the trace_check_vprintf()
function to make sure the pointers of the trace event are legit.

The addition of reading buffers from previous boots required adding a
delta between the addresses of the previous boot and the current boot so
that the pointers in the old buffer can still be used. But this required
adding a trace_array pointer to acquire the delta offsets.

The tp_printk code does not provide a trace_array (tr) pointer, so when
the offsets were examined, a NULL pointer dereference happened and the
kernel crashed.

If the trace_array does not exist, just default the delta offsets to zero,
as that also means the trace event is not being read from a previous boot.

Link: https://lore.kernel.org/all/Zv3z5UsG_jsO9_Tb@aschofie-mobl2.lan/

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20241003104925.4e1b1fd9@gandalf.local.home
Fixes: 07714b4b ("tracing: Handle old buffer mappings for event strings and functions")
Reported-by: default avatarAlison Schofield <alison.schofield@intel.com>
Tested-by: default avatarAlison Schofield <alison.schofield@intel.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 9852d85e
...@@ -3697,8 +3697,8 @@ static void test_can_verify(void) ...@@ -3697,8 +3697,8 @@ static void test_can_verify(void)
void trace_check_vprintf(struct trace_iterator *iter, const char *fmt, void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,
va_list ap) va_list ap)
{ {
long text_delta = iter->tr->text_delta; long text_delta = 0;
long data_delta = iter->tr->data_delta; long data_delta = 0;
const char *p = fmt; const char *p = fmt;
const char *str; const char *str;
bool good; bool good;
...@@ -3710,6 +3710,17 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt, ...@@ -3710,6 +3710,17 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,
if (static_branch_unlikely(&trace_no_verify)) if (static_branch_unlikely(&trace_no_verify))
goto print; goto print;
/*
* When the kernel is booted with the tp_printk command line
* parameter, trace events go directly through to printk().
* It also is checked by this function, but it does not
* have an associated trace_array (tr) for it.
*/
if (iter->tr) {
text_delta = iter->tr->text_delta;
data_delta = iter->tr->data_delta;
}
/* Don't bother checking when doing a ftrace_dump() */ /* Don't bother checking when doing a ftrace_dump() */
if (iter->fmt == static_fmt_buf) if (iter->fmt == static_fmt_buf)
goto print; goto print;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment