Skip to contentSkip to conversation

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

PATCH New Muchun Song 1 participant 1 message May 20, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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

---
 arch/x86/kernel/kprobes/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kprobes/ftrace.c +1 -1
index 681a4b36e9bbe..f1edc0dc860a2 100644
@@ -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);
 			}
Signature · 1 line
2.11.0