Skip to content

Commit e863d53

Browse files
mhiramatIngo Molnar
authored andcommitted
kprobes: Warn if optprobe handler tries to change execution path
Warn if optprobe handler tries to change execution path. As described in Documentation/kprobes.txt, with optprobe user handler can not change instruction pointer. In that case user must avoid optimizing the kprobes by setting post_handler or break_handler. Signed-off-by: Masami Hiramatsu <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E . McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/150581521955.32348.3615624715034787365.stgit@devbox Signed-off-by: Ingo Molnar <[email protected]>
1 parent cd52eda commit e863d53

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/kprobes.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
387387
list_for_each_entry_rcu(kp, &p->list, list) {
388388
if (kp->pre_handler && likely(!kprobe_disabled(kp))) {
389389
set_kprobe_instance(kp);
390-
kp->pre_handler(kp, regs);
390+
if (kp->pre_handler(kp, regs)) {
391+
if (WARN_ON_ONCE(1))
392+
pr_err("Optprobe ignores instruction pointer changing.(%pF)\n", p->addr);
393+
}
391394
}
392395
reset_kprobe_instance();
393396
}

0 commit comments

Comments
 (0)