[PATCH] kprobes/x86: Skip the assignment to ip when there is no post_handler

From: Muchun Song
Date: Wed May 20 2020 - 10:50:51 EST


When there is no post_handler, the assignment to ip of regs is
meaningless. So just skip it.

Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
---
arch/x86/kernel/kprobes/ftrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c
index 681a4b36e9bbe..f1edc0dc860a2 100644
--- a/arch/x86/kernel/kprobes/ftrace.c
+++ b/arch/x86/kernel/kprobes/ftrace.c
@@ -39,8 +39,8 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
* Emulate singlestep (and also recover regs->ip)
* as if there is a 5byte nop
*/
- regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
if (unlikely(p->post_handler)) {
+ regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
kcb->kprobe_status = KPROBE_HIT_SSDONE;
p->post_handler(p, regs, 0);
}
--
2.11.0