Skip to content

Commit 69d54b9

Browse files
WangNan0torvalds
authored andcommitted
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 <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> Cc: Ingo Molnar <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 977ad48 commit 69d54b9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

kernel/kprobes.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,8 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt)
869869
{
870870
struct kprobe *_p;
871871

872-
unoptimize_kprobe(p, false); /* Try to unoptimize */
872+
/* Try to unoptimize */
873+
unoptimize_kprobe(p, kprobes_all_disarmed);
873874

874875
if (!kprobe_queued(p)) {
875876
arch_disarm_kprobe(p);
@@ -1571,7 +1572,13 @@ static struct kprobe *__disable_kprobe(struct kprobe *p)
15711572

15721573
/* Try to disarm and disable this/parent probe */
15731574
if (p == orig_p || aggr_kprobe_disabled(orig_p)) {
1574-
disarm_kprobe(orig_p, true);
1575+
/*
1576+
* If kprobes_all_disarmed is set, orig_p
1577+
* should have already been disarmed, so
1578+
* skip unneed disarming process.
1579+
*/
1580+
if (!kprobes_all_disarmed)
1581+
disarm_kprobe(orig_p, true);
15751582
orig_p->flags |= KPROBE_FLAG_DISABLED;
15761583
}
15771584
}

0 commit comments

Comments
 (0)