Skip to content

Commit 2ef75e9

Browse files
Nikita Yushchenkorostedt
authored andcommitted
tracing: Don't use out-of-sync va_list in event printing
If trace_seq becomes full, trace_seq_vprintf() no longer consumes arguments from va_list, making va_list out of sync with format processing by trace_check_vprintf(). This causes va_arg() in trace_check_vprintf() to return wrong positional argument, which results into a WARN_ON_ONCE() hit. ftrace_stress_test from LTP triggers this situation. Fix it by explicitly avoiding further use if va_list at the point when it's consistency can no longer be guaranteed. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Nikita Yushchenko <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent c4c1dbc commit 2ef75e9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

kernel/trace/trace.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,6 +3812,18 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,
38123812
iter->fmt[i] = '\0';
38133813
trace_seq_vprintf(&iter->seq, iter->fmt, ap);
38143814

3815+
/*
3816+
* If iter->seq is full, the above call no longer guarantees
3817+
* that ap is in sync with fmt processing, and further calls
3818+
* to va_arg() can return wrong positional arguments.
3819+
*
3820+
* Ensure that ap is no longer used in this case.
3821+
*/
3822+
if (iter->seq.full) {
3823+
p = "";
3824+
break;
3825+
}
3826+
38153827
if (star)
38163828
len = va_arg(ap, int);
38173829

0 commit comments

Comments
 (0)