From: yangbo@deepin.com
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Laura Abbott <labbott@redhat.com>,
linux-kernel@vger.kernel.org, Yang Bo <yangbo@deepin.com>
Subject: [PATCH] x86/kprobe: unbalanced preempt counter with CONFIG_PREEMPT=y
Date: Mon, 15 Jan 2018 12:25:01 +0800 [thread overview]
Message-ID: <20180115042501.20882-1-yangbo@deepin.com> (raw)
From: Yang Bo <yangbo@deepin.com>
For each kprobe hook, preempt_disable() is called twice, but
preempt_enable() is called once, when CONFIG_PREEMPT=y. No
matter kprobe uses ftrace or int3. Then the preempt counter
overflows, the process might be preempted and migrate to another
cpu. It causes the kprobe int3 being treated as not kprobe's int3,
kernel dies.
The backtrace looks like this:
int3: 0000 [#1] PREEMPT SMP
Modules linkedd in: ...
CPU: 1 PID: 2618 COMM: ...
Hardware: ...
task: ...
RIP: 0010[<ffffffff81457cd5>] [<ffffffff81457cd5>] jprobe_return_end+0x0/0xb
...
RIP [<ffffffff81457cd5>] jprobe_return_end+0x0/0xb
RSP ...
Signed-off-by: Yang Bo <yangbo@deepin.com>
---
arch/x86/kernel/kprobes/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index bd36f3c33cd0..1ea5c9caa8f1 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -611,6 +611,7 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
regs->ip = (unsigned long)p->addr;
else
regs->ip = (unsigned long)p->ainsn.insn;
+ preempt_enable_no_resched();
}
NOKPROBE_SYMBOL(setup_singlestep);
--
2.15.1
next reply other threads:[~2018-01-15 4:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 4:25 yangbo [this message]
2018-03-01 21:12 ` Thomas Gleixner
2018-03-02 0:42 ` Masami Hiramatsu
2018-03-02 8:36 ` Thomas Gleixner
2018-03-03 1:20 ` 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=20180115042501.20882-1-yangbo@deepin.com \
--to=yangbo@deepin.com \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®