Skip to content

Commit

Permalink
x86/dumpstack/ftrace: Mark function graph handler function as unreliable
Browse files Browse the repository at this point in the history
When function graph tracing is enabled for a function, its return
address on the stack is replaced with the address of an ftrace handler
(return_to_handler).

Currently 'return_to_handler' can be reported as reliable.  That's not
ideal, and can actually be misleading.  When saving or dumping the
stack, you normally only care about what led up to that point (the call
path), rather than what will happen in the future (the return path).

That's especially true in the non-oops stack trace case, which isn't
used for debugging.  For example, in a perf profiling operation,
reporting return_to_handler() in the trace would just be confusing.

And in the oops case, where debugging is important, "unreliable" is also
more appropriate there because it serves as a hint that graph tracing
was involved, instead of trying to imply that return_to_handler() was
the real caller.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/f8af15749c7d632d3e7f815995831d5b7f82950d.1471607358.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Josh Poimboeuf authored and Ingo Molnar committed Aug 24, 2016
1 parent 471bd10 commit 6f727b8
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions arch/x86/kernel/dumpstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,21 @@ print_context_stack(struct task_struct *task,
bp = (unsigned long) frame;
}

ops->address(data, addr, reliable);

/*
* When function graph tracing is enabled for a
* function, its return address on the stack is
* replaced with the address of an ftrace handler
* (return_to_handler). In that case, before printing
* the "real" address, we want to print the handler
* address as an "unreliable" hint that function graph
* tracing was involved.
*/
real_addr = ftrace_graph_ret_addr(task, graph, addr,
stack);
if (real_addr != addr)
ops->address(data, real_addr, 1);
ops->address(data, addr, 0);

ops->address(data, real_addr, reliable);
}
stack++;
}
Expand All @@ -116,12 +125,11 @@ print_context_stack_bp(struct task_struct *task,
if (!__kernel_text_address(addr))
break;

if (ops->address(data, addr, 1))
break;

real_addr = ftrace_graph_ret_addr(task, graph, addr, retp);
if (real_addr != addr)
ops->address(data, real_addr, 1);
if (real_addr != addr && ops->address(data, addr, 0))
break;
if (ops->address(data, real_addr, 1))
break;

frame = frame->next_frame;
retp = &frame->return_address;
Expand Down

0 comments on commit 6f727b8

Please sign in to comment.