From: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H . Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
systemtap@sourceware.org, Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH tip/master] [BUGFIX] kprobes/x86: Fix to clear TF bit in fault-on-single-stepping
Date: Mon, 13 Jun 2016 10:00:33 +0530 [thread overview]
Message-ID: <20160613043033.GA22985@in.ibm.com> (raw)
In-Reply-To: <20160611140648.25885.37482.stgit@devbox>
On Sat, Jun 11, 2016 at 11:06:53PM +0900, Masami Hiramatsu wrote:
> Fix kprobe_fault_handler to clear TF (trap flag) bit of
> flags register in the case of fault fixup on single-stepping.
>
> If we put a kprobe on the instruction which can cause a
> page fault (e.g. actual mov instructions in copy_user_*),
> that fault happens on a single-stepping buffer. In this
> case, kprobes resets running instance so that the CPU can
> retry execution on the original ip address.
> However, current code forgets reset TF bit. Since this
> fault happens with TF bit set for enabling single-stepping,
> when it retries, it causes a debug exception and kprobes
> can not handle it because it already reset itself.
>
> On the most of x86-64 platform, it can be easily reproduced
> by using kprobe tracer. E.g.
>
> # cd /sys/kernel/debug/tracing
> # echo p copy_user_enhanced_fast_string+5 > kprobe_events
> # echo 1 > events/kprobes/enable
>
> And you'll see a kernel panic on do_debug(), since the debug
> trap is not handled by kprobes.
>
> To fix this problem, we just need to clear the TF bit when
> resetting running kprobe.
>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Good catch!
Reviewed-by: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
next prev parent reply other threads:[~2016-06-13 4:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-11 14:06 [PATCH tip/master] [BUGFIX] kprobes/x86: Fix to clear TF bit in fault-on-single-stepping Masami Hiramatsu
2016-06-13 4:30 ` Ananth N Mavinakayanahalli [this message]
2016-06-13 23:13 ` Steven Rostedt
2016-06-13 23:20 ` Steven Rostedt
2016-06-14 1:19 ` Masami Hiramatsu
2016-06-14 9:59 ` Ingo Molnar
2016-06-14 11:31 ` [tip:perf/urgent] kprobes/x86: Clear TF bit in fault on single-stepping tip-bot for 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=20160613043033.GA22985@in.ibm.com \
--to=ananth@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=systemtap@sourceware.org \
--cc=tglx@linutronix.de \
/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 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.