x86/ibt,ftrace: Make function-graph play nice
authorPeter Zijlstra <peterz@infradead.org>
Tue, 16 Aug 2022 08:26:57 +0000 (05:26 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Aug 2022 13:17:48 +0000 (15:17 +0200)
commit543138c555185e5054f9095909761f1bca9096ba
tree98725affc800a9d863a523b9df11853a7250d9a8
parentf6632763484c6078f65eff3fd0044cc2bc82fd18
x86/ibt,ftrace: Make function-graph play nice

commit e52fc2cf3f662828cc0d51c4b73bed73ad275fce upstream.

Return trampoline must not use indirect branch to return; while this
preserves the RSB, it is fundamentally incompatible with IBT. Instead
use a retpoline like ROP gadget that defeats IBT while not unbalancing
the RSB.

And since ftrace_stub is no longer a plain RET, don't use it to copy
from. Since RET is a trivial instruction, poke it directly.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154318.347296408@infradead.org
[cascardo: remove ENDBR]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/ftrace.c
arch/x86/kernel/ftrace_64.S