lkml.org 
[lkml]   [2021]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: User stacktrace garbage when USER_STACKTRACE_SUPPORT is not enabled
On Wed, Mar 31, 2021 at 10:37:49AM -0400, Steven Rostedt wrote:
> But after writing all of the above, I think I found a bug! It's this:
>
> size = nr_entries * sizeof(unsigned long);
> event = __trace_buffer_lock_reserve(buffer, TRACE_STACK,
> sizeof(*entry) + size, trace_ctx);
>
>
> I said the above commit did not play a role in output, but it does play a
> role in creating the struct stack_trace entry. And by making it a fixed
> array (even though it's not used) it added 8 more entries to the stack!
>
> This should fix the problem:
>
> -- Steve
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 3c605957bb5c..507a30bf26e4 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -2985,7 +2985,8 @@ static void __ftrace_trace_stack(struct trace_buffer *buffer,
>
> size = nr_entries * sizeof(unsigned long);
> event = __trace_buffer_lock_reserve(buffer, TRACE_STACK,
> - sizeof(*entry) + size, trace_ctx);
> + (sizeof(*entry) - sizeof(entry->caller)) + size,
> + trace_ctx);
> if (!event)
> goto out;
> entry = ring_buffer_event_data(event);

It does! Thanks for the explanation and for the fix. I wonder why nobody
noticed and complained about that since v5.6.

Acked-by: Vasily Gorbik <gor@linux.ibm.com>

\
 
 \ /
  Last update: 2021-03-31 22:53    [W:0.046 / U:0.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site