public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <righi.andrea@gmail.com>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	peterz@infradead.org,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH v2 0/9] kprobes: Fix and improve blacklist symbols
Date: Sat, 12 Jan 2019 14:33:24 +0100	[thread overview]
Message-ID: <20190112133324.GA2009@xps-13> (raw)
In-Reply-To: <154725993986.18060.2759150647140353514.stgit@devbox>

On Sat, Jan 12, 2019 at 11:25:40AM +0900, Masami Hiramatsu wrote:
...
> And I found several functions which must be blacklisted.
>  - optprobe template code, which is just a template code and
>    never be executed. Moreover, since it can be copied and
>    reused, if we probe it, it modifies the template code and
>    can cause a crash. ([1/9][2/9])
>  - functions which is called before kprobe_int3_handler()
>    handles kprobes. This can cause a breakpoint recursion. ([3/9])
>  - IRQ entry text, which should not be probed since register/pagetable
>    status has not been stable at that point. ([4/9])
>  - Suffixed symbols, like .constprop, .part etc. Those suffixed
>    symbols never be blacklisted even if the non-suffixed version
>    has been blacklisted. ([5/9])
>  - hardirq tracer also works before int3 handling. ([6/9])
>  - preempt_check debug function also is involved in int3 handling.
>    ([7/9])
>  - RCU debug routine is also called before kprobe_int3_handler().
>    ([8/9])
>  - Some lockdep functions are also involved in int3 handling.
>    ([9/9])
> 
> Of course there still may be some functions which can be called
> by configuration change, I'll continue to test it.

Hi Masami,

I think I've found another recursion problem. Could you include also
this one?

Thanks,

From: Andrea Righi <righi.andrea@gmail.com>
Subject: [PATCH] kprobes: prohibit probing on bsearch()

Since kprobe breakpoing handler is using bsearch(), probing on this
routine can cause recursive breakpoint problem.

int3
 ->do_int3()
   ->ftrace_int3_handler()
     ->ftrace_location()
       ->ftrace_location_range()
         ->bsearch() -> int3

Prohibit probing on bsearch().

Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
---
 lib/bsearch.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/bsearch.c b/lib/bsearch.c
index 18b445b010c3..82512fe7b33c 100644
--- a/lib/bsearch.c
+++ b/lib/bsearch.c
@@ -11,6 +11,7 @@
 
 #include <linux/export.h>
 #include <linux/bsearch.h>
+#include <linux/kprobes.h>
 
 /*
  * bsearch - binary search an array of elements
@@ -53,3 +54,4 @@ void *bsearch(const void *key, const void *base, size_t num, size_t size,
 	return NULL;
 }
 EXPORT_SYMBOL(bsearch);
+NOKPROBE_SYMBOL(bsearch);
-- 
2.17.1


  parent reply	other threads:[~2019-01-12 13:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-12  2:25 [PATCH v2 0/9] kprobes: Fix and improve blacklist symbols Masami Hiramatsu
2019-01-12  2:26 ` [PATCH v2 1/9] x86/kprobes: Prohibit probing on optprobe template code Masami Hiramatsu
2019-01-12  2:26 ` [PATCH v2 2/9] x86/kprobes: Move trampoline code into RODATA Masami Hiramatsu
2019-01-12  2:27 ` [PATCH v2 3/9] x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() Masami Hiramatsu
2019-01-12  2:27 ` [PATCH v2 4/9] x86/kprobes: Prohibit probing on IRQ handlers directly Masami Hiramatsu
2019-01-12  2:28 ` [PATCH v2 5/9] kprobes: Search non-suffixed symbol in blacklist Masami Hiramatsu
2019-01-14 16:16   ` Steven Rostedt
2019-01-12  2:28 ` [PATCH v2 6/9] kprobes: Prohibit probing on hardirq tracers Masami Hiramatsu
2019-01-12  2:28 ` [PATCH v2 7/9] kprobes: Prohibit probing on preempt_check debug functions Masami Hiramatsu
2019-01-12  2:29 ` [PATCH v2 8/9] kprobes: Prohibit probing on RCU debug routine Masami Hiramatsu
2019-01-12  2:29 ` [PATCH v2 9/9] kprobes: Prohibit probing on lockdep functions Masami Hiramatsu
2019-01-12 13:33 ` Andrea Righi [this message]
2019-01-13 14:23   ` [PATCH v2 0/9] kprobes: Fix and improve blacklist symbols Masami Hiramatsu
2019-01-14 16:18 ` Steven Rostedt
2019-02-01 13:31   ` Masami Hiramatsu
2019-02-11 13:50     ` Ingo Molnar
2019-02-12 16:48       ` 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=20190112133324.GA2009@xps-13 \
    --to=righi.andrea@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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