Re: [PATCH] tracing: Fix out-of-range read in trace_stack_print()
From: Steven Rostedt
Date: Fri Jun 14 2019 - 16:36:30 EST
On Mon, 10 Jun 2019 13:00:16 +0900
Eiichi Tsukata <devel@xxxxxxxxxxxx> wrote:
> Puts range check before dereferencing the pointer.
>
> Reproducer:
>
> # echo stacktrace > trace_options
> # echo 1 > events/enable
> # cat trace > /dev/null
>
>
Thanks I applied this.
>
> Fixes: 4a9bd3f134dec ("tracing: Have dynamic size event stack traces")
Actually it fixes:
4285f2fcef80 ("tracing: Remove the ULONG_MAX stack trace hackery")
Because before that, a ULONG_MAX was inserted into the buffer.
-- Steve
> Signed-off-by: Eiichi Tsukata <devel@xxxxxxxxxxxx>
> ---
> kernel/trace/trace_output.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
> index 54373d93e251..ba751f993c3b 100644
> --- a/kernel/trace/trace_output.c
> +++ b/kernel/trace/trace_output.c
> @@ -1057,7 +1057,7 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
>
> trace_seq_puts(s, "<stack trace>\n");
>
> - for (p = field->caller; p && *p != ULONG_MAX && p < end; p++) {
> + for (p = field->caller; p && p < end && *p != ULONG_MAX; p++) {
>
> if (trace_seq_has_overflowed(s))
> break;