The previous change (Fixes commit) messed up the rsp register value,
which is wrong because it's already adjusted with FRAME_SIZE, we need
the original value (after UNWIND_HINT_FUNC hint).

Fixes: 20a0bc10272f ("x86/fgraph,bpf: Fix stack ORC unwind from kprobe_multi 
return probe")
Signed-off-by: Jiri Olsa <[email protected]>
---
 arch/x86/kernel/ftrace_64.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
index a132608265f6..613be81b6e88 100644
--- a/arch/x86/kernel/ftrace_64.S
+++ b/arch/x86/kernel/ftrace_64.S
@@ -368,13 +368,15 @@ SYM_CODE_START(return_to_handler)
        subq $8, %rsp
        UNWIND_HINT_FUNC
 
+       movq %rsp, %rdi
+
        /* Save ftrace_regs for function exit context  */
        subq $(FRAME_SIZE), %rsp
 
        movq %rax, RAX(%rsp)
        movq %rdx, RDX(%rsp)
        movq %rbp, RBP(%rsp)
-       movq %rsp, RSP(%rsp)
+       movq %rdi, RSP(%rsp)
        movq %rsp, %rdi
 
        call ftrace_return_to_handler
-- 
2.52.0


Reply via email to