Skip to content

Commit 5efd3e2

Browse files
committed
tracing: Remove precision vsnprintf() check from print event
This reverts 60be76e ("tracing: Add size check when printing trace_marker output"). The only reason the precision check was added was because of a bug that miscalculated the write size of the string into the ring buffer and it truncated it removing the terminating nul byte. On reading the trace it crashed the kernel. But this was due to the bug in the code that happened during development and should never happen in practice. If anything, the precision can hide bugs where the string in the ring buffer isn't nul terminated and it will not be checked. Link: https://lore.kernel.org/all/C7E7AF1A-D30F-4D18-B8E5-AF1EF58004F5@linux.ibm.com/ Link: https://lore.kernel.org/linux-trace-kernel/20240227125706.04279ac2@gandalf.local.home Link: https://lore.kernel.org/all/20240302111244.3a1674be@gandalf.local.home/ Link: https://lore.kernel.org/linux-trace-kernel/20240304174341.2a561d9f@gandalf.local.home Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Fixes: 60be76e ("tracing: Add size check when printing trace_marker output") Reported-by: Sachin Sant <sachinp@linux.ibm.com> Tested-by: Sachin Sant <sachinp@linux.ibm.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent e78fb4e commit 5efd3e2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/trace/trace_output.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,12 +1587,11 @@ static enum print_line_t trace_print_print(struct trace_iterator *iter,
15871587
{
15881588
struct print_entry *field;
15891589
struct trace_seq *s = &iter->seq;
1590-
int max = iter->ent_size - offsetof(struct print_entry, buf);
15911590

15921591
trace_assign_type(field, iter->ent);
15931592

15941593
seq_print_ip_sym(s, field->ip, flags);
1595-
trace_seq_printf(s, ": %.*s", max, field->buf);
1594+
trace_seq_printf(s, ": %s", field->buf);
15961595

15971596
return trace_handle_return(s);
15981597
}
@@ -1601,11 +1600,10 @@ static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags,
16011600
struct trace_event *event)
16021601
{
16031602
struct print_entry *field;
1604-
int max = iter->ent_size - offsetof(struct print_entry, buf);
16051603

16061604
trace_assign_type(field, iter->ent);
16071605

1608-
trace_seq_printf(&iter->seq, "# %lx %.*s", field->ip, max, field->buf);
1606+
trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf);
16091607

16101608
return trace_handle_return(&iter->seq);
16111609
}

0 commit comments

Comments
 (0)