Skip to content

Commit 1fe5501

Browse files
committed
Merge tag 'trace-v5.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fix from Steven Rostedt: "Fix tp_printk command line and trace events Masami added a wrapper to be able to unhash trace event pointers as they are only read by root anyway, and they can also be extracted by the raw trace data buffers. But this wrapper utilized the iterator to have a temporary buffer to manipulate the text with. tp_printk is a kernel command line option that will send the trace output of a trace event to the console on boot up (useful when the system crashes before finishing the boot). But the code used the same wrapper that Masami added, and its iterator did not have a buffer, and this caused the system to crash. Have the wrapper just print the trace event normally if the iterator has no temporary buffer" * tag 'trace-v5.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix checking event hash pointer logic when tp_printk is enabled
2 parents db2e718 + 0e1e71d commit 1fe5501

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

kernel/trace/trace.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,7 +3545,11 @@ static char *trace_iter_expand_format(struct trace_iterator *iter)
35453545
{
35463546
char *tmp;
35473547

3548-
if (iter->fmt == static_fmt_buf)
3548+
/*
3549+
* iter->tr is NULL when used with tp_printk, which makes
3550+
* this get called where it is not safe to call krealloc().
3551+
*/
3552+
if (!iter->tr || iter->fmt == static_fmt_buf)
35493553
return NULL;
35503554

35513555
tmp = krealloc(iter->fmt, iter->fmt_size + STATIC_FMT_BUF_SIZE,
@@ -3566,7 +3570,7 @@ const char *trace_event_format(struct trace_iterator *iter, const char *fmt)
35663570
if (WARN_ON_ONCE(!fmt))
35673571
return fmt;
35683572

3569-
if (iter->tr->trace_flags & TRACE_ITER_HASH_PTR)
3573+
if (!iter->tr || iter->tr->trace_flags & TRACE_ITER_HASH_PTR)
35703574
return fmt;
35713575

35723576
p = fmt;
@@ -9692,7 +9696,7 @@ void __init early_trace_init(void)
96929696
{
96939697
if (tracepoint_printk) {
96949698
tracepoint_print_iter =
9695-
kmalloc(sizeof(*tracepoint_print_iter), GFP_KERNEL);
9699+
kzalloc(sizeof(*tracepoint_print_iter), GFP_KERNEL);
96969700
if (MEM_FAIL(!tracepoint_print_iter,
96979701
"Failed to allocate trace iterator\n"))
96989702
tracepoint_printk = 0;

0 commit comments

Comments
 (0)