All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kprobes: bugfix: force unoptimize when disable kprobes.
@ 2015-01-05 12:32 ` Wang Nan
  0 siblings, 0 replies; 22+ messages in thread
From: Wang Nan @ 2015-01-05 12:32 UTC (permalink / raw)
  To: masami.hiramatsu.pt, tixy, linux; +Cc: linux-kernel, linux-arm-kernel, lizefan

Original code failed to disarm the probed instruction after

echo 0 > /sys/kernel/debug/kprobes/enabled

if OPTPROBE is enabled.

This is caused by a piece of logically inconsistent code:

	unoptimize_kprobe(p, false);
	if (!kprobe_queued(p)) {
		...
	}

unoptimize_kprobe() with 'force' == false queues p onto
unoptimizing_list, so following kprobe_queued() check always fail unless
another core schedules optimizer and does the unoptimization very soon.
This logic causes arch_disarm_kprobe() failed to get execute, lefts a
breakpoint at the probed address, instead of restoring it.

This patch uses force unoptimize instead.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
---
 kernel/kprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index b185464..9fbe0c3 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -869,7 +869,7 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt)
 {
 	struct kprobe *_p;
 
-	unoptimize_kprobe(p, false);	/* Try to unoptimize */
+	unoptimize_kprobe(p, true);	/* Try to unoptimize */
 
 	if (!kprobe_queued(p)) {
 		arch_disarm_kprobe(p);
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-01-20  7:12 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-05 12:32 [PATCH] kprobes: bugfix: force unoptimize when disable kprobes Wang Nan
2015-01-05 12:32 ` Wang Nan
2015-01-12 11:42 ` Masami Hiramatsu
2015-01-12 11:42   ` Masami Hiramatsu
2015-01-12 12:09   ` [PATCH] kprobes: bugfix: checks kprobes_all_disarmed in unoptimized_kprobe() Wang Nan
2015-01-12 12:09     ` Wang Nan
2015-01-12 12:52     ` Masami Hiramatsu
2015-01-12 12:52       ` Masami Hiramatsu
2015-01-19  3:04       ` Wang Nan
2015-01-19  3:04         ` Wang Nan
2015-01-19  9:05         ` Masami Hiramatsu
2015-01-19  9:05           ` Masami Hiramatsu
2015-01-19 11:21           ` Wang Nan
2015-01-19 11:21             ` Wang Nan
2015-01-19 12:45             ` Masami Hiramatsu
2015-01-19 12:45               ` Masami Hiramatsu
2015-01-19 12:59               ` Wang Nan
2015-01-19 12:59                 ` Wang Nan
2015-01-20  2:51               ` [PATCH] kprobes: bugfix: makes kprobes/enabled works correctly for optimized kprobes Wang Nan
2015-01-20  2:51                 ` Wang Nan
2015-01-20  7:12                 ` Masami Hiramatsu
2015-01-20  7:12                   ` Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.