x86/ftrace: Make it call depth tracking aware
Since ftrace has trampolines, don't use thunks for the __fentry__ site but instead require that every function called from there includes accounting. This very much includes all the direct-call functions. Additionally, ftrace uses ROP tricks in two places: - return_to_handler(), and - ftrace_regs_caller() when pt_regs->orig_ax is set by a direct-call. return_to_handler() already uses a retpoline to replace an indirect-jump to defeat IBT, since this is a jump-type retpoline, make sure there is no accounting done and ALTERNATIVE the RET into a ret. ftrace_regs_caller() does much the same and gets the same treatment. Signed-off-by:Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by:
Thomas Gleixner <tglx@linutronix.de> Signed-off-by:
Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20220915111148.927545073@infradead.org
Showing
- arch/x86/include/asm/nospec-branch.h 9 additions, 0 deletionsarch/x86/include/asm/nospec-branch.h
- arch/x86/kernel/callthunks.c 1 addition, 1 deletionarch/x86/kernel/callthunks.c
- arch/x86/kernel/ftrace.c 12 additions, 4 deletionsarch/x86/kernel/ftrace.c
- arch/x86/kernel/ftrace_64.S 20 additions, 2 deletionsarch/x86/kernel/ftrace_64.S
- arch/x86/net/bpf_jit_comp.c 6 additions, 0 deletionsarch/x86/net/bpf_jit_comp.c
- kernel/trace/trace_selftest.c 8 additions, 1 deletionkernel/trace/trace_selftest.c
- samples/ftrace/ftrace-direct-modify.c 3 additions, 0 deletionssamples/ftrace/ftrace-direct-modify.c
- samples/ftrace/ftrace-direct-multi-modify.c 3 additions, 0 deletionssamples/ftrace/ftrace-direct-multi-modify.c
- samples/ftrace/ftrace-direct-multi.c 2 additions, 0 deletionssamples/ftrace/ftrace-direct-multi.c
- samples/ftrace/ftrace-direct-too.c 2 additions, 0 deletionssamples/ftrace/ftrace-direct-too.c
- samples/ftrace/ftrace-direct.c 2 additions, 0 deletionssamples/ftrace/ftrace-direct.c
Loading
Please register or sign in to comment