[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-e863d5396146411b615231cae0c518cb2a23371c@git.kernel.org>
Date: Thu, 28 Sep 2017 03:53:21 -0700
From: tip-bot for Masami Hiramatsu <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: ast@...nel.org, ast@...com, mhiramat@...nel.org,
ananth@...ux.vnet.ibm.com, mingo@...nel.org, peterz@...radead.org,
rostedt@...dmis.org, linux-kernel@...r.kernel.org,
torvalds@...ux-foundation.org, hpa@...or.com,
paulmck@...ux.vnet.ibm.com, tglx@...utronix.de
Subject: [tip:perf/core] kprobes: Warn if optprobe handler tries to change
execution path
Commit-ID: e863d5396146411b615231cae0c518cb2a23371c
Gitweb: https://git.kernel.org/tip/e863d5396146411b615231cae0c518cb2a23371c
Author: Masami Hiramatsu <mhiramat@...nel.org>
AuthorDate: Tue, 19 Sep 2017 19:00:19 +0900
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Thu, 28 Sep 2017 09:23:04 +0200
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 <mhiramat@...nel.org>
Cc: Alexei Starovoitov <ast@...com>
Cc: Alexei Starovoitov <ast@...nel.org>
Cc: Ananth N Mavinakayanahalli <ananth@...ux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Paul E . McKenney <paulmck@...ux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Link: http://lkml.kernel.org/r/150581521955.32348.3615624715034787365.stgit@devbox
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/kprobes.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 15fba7f..2d28377 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();
}
Powered by blists - more mailing lists