From: wangnan0@huawei.com (Wang Nan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] kprobes: bugfix: force unoptimize when disable kprobes.
Date: Mon, 5 Jan 2015 20:32:20 +0800 [thread overview]
Message-ID: <1420461140-27153-1-git-send-email-wangnan0@huawei.com> (raw)
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
next reply other threads:[~2015-01-05 12:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-05 12:32 Wang Nan [this message]
2015-01-12 11:42 ` [PATCH] kprobes: bugfix: force unoptimize when disable kprobes Masami Hiramatsu
2015-01-12 12:09 ` [PATCH] kprobes: bugfix: checks kprobes_all_disarmed in unoptimized_kprobe() Wang Nan
2015-01-12 12:52 ` Masami Hiramatsu
2015-01-19 3:04 ` Wang Nan
2015-01-19 9:05 ` Masami Hiramatsu
2015-01-19 11:21 ` Wang Nan
2015-01-19 12:45 ` Masami Hiramatsu
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 7:12 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420461140-27153-1-git-send-email-wangnan0@huawei.com \
--to=wangnan0@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).