summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2015-02-13 23:40:26 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 06:21:42 +0100
commit69d54b916d83872a0a327778a01af2a096923f59 (patch)
treeee62261a484b8e939ad763e2cf4e8039ca9658ea /kernel
parentkprobes: set kprobes_all_disarmed earlier to enable re-optimization. (diff)
downloadlinux-69d54b916d83872a0a327778a01af2a096923f59.tar.xz
linux-69d54b916d83872a0a327778a01af2a096923f59.zip
kprobes: makes kprobes/enabled works correctly for optimized kprobes.
debugfs/kprobes/enabled doesn't work correctly on optimized kprobes. Masami Hiramatsu has a test report on x86_64 platform: https://lkml.org/lkml/2015/1/19/274 This patch forces it to unoptimize kprobe if kprobes_all_disarmed is set. It also checks the flag in unregistering path for skipping unneeded disarming process when kprobes globally disarmed. Signed-off-by: Wang Nan <wangnan0@huawei.com> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kprobes.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c39790001854..c90e417bb963 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -869,7 +869,8 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt)
{
struct kprobe *_p;
- unoptimize_kprobe(p, false); /* Try to unoptimize */
+ /* Try to unoptimize */
+ unoptimize_kprobe(p, kprobes_all_disarmed);
if (!kprobe_queued(p)) {
arch_disarm_kprobe(p);
@@ -1571,7 +1572,13 @@ static struct kprobe *__disable_kprobe(struct kprobe *p)
/* Try to disarm and disable this/parent probe */
if (p == orig_p || aggr_kprobe_disabled(orig_p)) {
- disarm_kprobe(orig_p, true);
+ /*
+ * If kprobes_all_disarmed is set, orig_p
+ * should have already been disarmed, so
+ * skip unneed disarming process.
+ */
+ if (!kprobes_all_disarmed)
+ disarm_kprobe(orig_p, true);
orig_p->flags |= KPROBE_FLAG_DISABLED;
}
}