From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC][PATCH] kprobes/x86: While list ftrace locations in kprobe blacklist areas
Date: Fri, 11 Oct 2019 17:39:29 +0900 [thread overview]
Message-ID: <20191011173929.9462a1414ff3a94ec93d6e98@kernel.org> (raw)
In-Reply-To: <20191010175216.4ceb3cf1@gandalf.local.home>
Hi Steve,
On Thu, 10 Oct 2019 17:52:16 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> I noticed some of my old tests failing on kprobes, and realized that
> this was due to black listing irq_entry functions on x86 from being
> used by kprobes. IIRC, this was due to the cr2 being corrupted and
> such, and I believe other things were to cause. But black listing all
> irq_entry code is a big hammer to this.
OK, I think if we can use ftrace for hooking, probing on "that address"
is good, but the function body still can not be probed.
>
> (See commit 0eae81dc9f026 "x86/kprobes: Prohibit probing on IRQ
> handlers directly" for more details)
>
> Anyway, if kprobes is using ftrace as a hook, there shouldn't be any
> problems here. If we white list ftrace locations in the range of
> kprobe_add_area_blacklist(), it should be safe.
Agreed.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index d9770a5393c8..9d28a279282c 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -2124,6 +2124,11 @@ int kprobe_add_area_blacklist(unsigned long start, unsigned long end)
> int ret = 0;
>
> for (entry = start; entry < end; entry += ret) {
> +#ifdef CONFIG_KPROBES_ON_FTRACE
> + /* We are safe if using ftrace */
> + if (ftrace_location(entry))
> + continue;
> +#endif
Have you tested the patch? it doesn't measure the entry function's size.
(kprobe_add_ksym_blacklist(entry) returns the function size)
Could you do this in kprobe_add_ksym_blacklist()?
Instead of continue, increment ent->start_addr by MCOUNT size(?) will be OK.
(Note that since each blacklist symbol is managed independently, you can make
a "gap" between them as a safe area)
Thank you,
> ret = kprobe_add_ksym_blacklist(entry);
> if (ret < 0)
> return ret;
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2019-10-11 8:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 21:52 [RFC][PATCH] kprobes/x86: While list ftrace locations in kprobe blacklist areas Steven Rostedt
2019-10-10 21:55 ` Steven Rostedt
2019-10-11 8:39 ` Masami Hiramatsu [this message]
2019-10-11 13:12 ` Steven Rostedt
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=20191011173929.9462a1414ff3a94ec93d6e98@kernel.org \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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 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).