Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1734781

[PATCH -tip v3 3/7] kprobes: Warn if optprobe handler tries to change execution path

From Masami Hiramatsu <mhiramat@kernel.org>
Newsgroups linux.kernel
Subject [PATCH -tip v3 3/7] kprobes: Warn if optprobe handler tries to change execution path
Date 2017-09-19 12:10 +0200
Message-ID <urnDA-3YD-5@gated-at.bofh.it> (permalink)
References <urntU-3th-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <mhiramat@kernel.org>
---
 kernel/kprobes.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a1606a4224e1..de73b843c623 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -387,7 +387,10 @@ void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
 	list_for_each_entry_rcu(kp, &p->list, list) {
 		if (kp->pre_handler && likely(!kprobe_disabled(kp))) {
 			set_kprobe_instance(kp);
-			kp->pre_handler(kp, regs);
+			if (kp->pre_handler(kp, regs)) {
+				if (WARN_ON_ONCE(1))
+					pr_err("Optprobe ignores instruction pointer changing.(%pF)\n", p->addr);
+			}
 		}
 		reset_kprobe_instance();
 	}

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH -tip v3 0/7] kprobes/x86: Preempt related enhancements Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:00 +0200
  [PATCH -tip v3 1/7] kprobes: Improve smoke test to check preemptible Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:00 +0200
  [PATCH -tip v3 7/7] kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:10 +0200
  [PATCH -tip v3 3/7] kprobes: Warn if optprobe handler tries to change execution path Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:10 +0200
  [PATCH -tip v3 5/7] kprobes/x86: Disable preempt ftrace-based jprobe Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:10 +0200
  [PATCH -tip v3 4/7] kprobes/x86: Disable preempt in optprobe Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:10 +0200
  [PATCH -tip v3 2/7] kprobes/x86: Move get_kprobe_ctlblk in irq-disabled block Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:10 +0200
  [PATCH -tip v3 6/7] kprobes/x86: Remove disable_irq from ftrace-based/optimized kprobe Masami Hiramatsu <mhiramat@kernel.org> - 2017-09-19 12:10 +0200

csiph-web