OSDN Git Service

x86/ftrace: Do not call function graph from dynamic trampolines
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Sat, 8 Dec 2018 17:58:51 +0000 (12:58 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Jun 2019 07:17:24 +0000 (09:17 +0200)
commit6fa953c94882ebe73dcb545b4906ee849821e357
tree1f6d070c54ee6ac664c7a0b46e7b580b937a7c00
parent9d57cfd4e9d81400c1fe2b7cd4503f54830b46c2
x86/ftrace: Do not call function graph from dynamic trampolines

[ Upstream commit d2a68c4effd821f0871d20368f76b609349c8a3b ]

Since commit 79922b8009c07 ("ftrace: Optimize function graph to be
called directly"), dynamic trampolines should not be calling the
function graph tracer at the end. If they do, it could cause the function
graph tracer to trace functions that it filtered out.

Right now it does not cause a problem because there's a test to check if
the function graph tracer is attached to the same function as the
function tracer, which for now is true. But the function graph tracer is
undergoing changes that can make this no longer true which will cause
the function graph tracer to trace other functions.

 For example:

 # cd /sys/kernel/tracing/
 # echo do_IRQ > set_ftrace_filter
 # mkdir instances/foo
 # echo ip_rcv > instances/foo/set_ftrace_filter
 # echo function_graph > current_tracer
 # echo function > instances/foo/current_tracer

Would cause the function graph tracer to trace both do_IRQ and ip_rcv,
if the current tests change.

As the current tests prevent this from being a problem, this code does
not need to be backported. But it does make the code cleaner.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/ftrace.c
arch/x86/kernel/ftrace_64.S