linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -tip v3 00/10] kprobes: Fix and improve blacklist symbols
@ 2019-02-12 16:10 Masami Hiramatsu
  2019-02-12 16:11 ` [PATCH -tip v3 01/10] x86/kprobes: Prohibit probing on optprobe template code Masami Hiramatsu
                   ` (9 more replies)
  0 siblings, 10 replies; 28+ messages in thread
From: Masami Hiramatsu @ 2019-02-12 16:10 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Masami Hiramatsu, peterz, Mathieu Desnoyers, linux-kernel,
	Andrea Righi, Steven Rostedt

Hi,

Here is the v3 series of kprobes blacklist bugfix and improvements mainly
on x86 (since I started testing on qemu-x86).

This version is just rebased on top of -tip master branch and
add bsearch nokprobe patch by Andrea (Thanks!)

This has been started from discussion about KPROBE_ENENTS_ON_NOTRACE
configuration. I tried to find notrace functions which can cause kernel
crash with kprobes using following script.

====
#!/bin/sh

i=0;
cat notrace_functions | while read f ; do
  if echo p:event$i $f >> /sys/kernel/debug/tracing/kprobe_events; then
     echo "Probing on $f"
     echo 1 > /sys/kernel/debug/tracing/events/kprobes/event$i/enable 
  fi
  i=$((i+1))
done
====

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/10][2/10])
 - functions which is called before kprobe_int3_handler()
   handles kprobes. This can cause a breakpoint recursion. ([3/10])
 - IRQ entry text, which should not be probed since register/pagetable
   status has not been stable at that point. ([4/10])
 - Suffixed symbols, like .constprop, .part etc. Those suffixed
   symbols never be blacklisted even if the non-suffixed version
   has been blacklisted. ([5/10])
 - hardirq tracer also works before int3 handling. ([6/10])
 - preempt_check debug function also is involved in int3 handling.
   ([7/10])
 - RCU debug routine is also called before kprobe_int3_handler().
   ([8/10])
 - Some lockdep functions are also involved in int3 handling.
   ([9/10])
 - bsearch() is involved in int3 handling because of ftrace
   is using it. ([10/10])

Of course there still may be some functions which can be called
by configuration change, I'll continue to test it.

Thank you,

---

Andrea Righi (1):
      kprobes: Prohibit probing on bsearch()

Masami Hiramatsu (9):
      x86/kprobes: Prohibit probing on optprobe template code
      x86/kprobes: Move trampoline code into RODATA
      x86/kprobes: Prohibit probing on functions before kprobe_int3_handler()
      x86/kprobes: Prohibit probing on IRQ handlers directly
      kprobes: Search non-suffixed symbol in blacklist
      kprobes: Prohibit probing on hardirq tracers
      kprobes: Prohibit probing on preempt_check debug functions
      kprobes: Prohibit probing on RCU debug routine
      kprobes: Prohibit probing on lockdep functions


 arch/x86/kernel/alternative.c   |    3 ++-
 arch/x86/kernel/ftrace.c        |    3 ++-
 arch/x86/kernel/kprobes/core.c  |    7 +++++++
 arch/x86/kernel/kprobes/opt.c   |    4 ++--
 arch/x86/kernel/traps.c         |    1 +
 kernel/kprobes.c                |   21 ++++++++++++++++++++-
 kernel/locking/lockdep.c        |    7 ++++++-
 kernel/rcu/tree.c               |    2 ++
 kernel/rcu/update.c             |    2 ++
 kernel/trace/trace_irqsoff.c    |    9 +++++++--
 kernel/trace/trace_preemptirq.c |    5 +++++
 lib/bsearch.c                   |    2 ++
 lib/smp_processor_id.c          |    7 +++++--
 13 files changed, 63 insertions(+), 10 deletions(-)

-- 
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2019-03-26 15:17 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 16:10 [PATCH -tip v3 00/10] kprobes: Fix and improve blacklist symbols Masami Hiramatsu
2019-02-12 16:11 ` [PATCH -tip v3 01/10] x86/kprobes: Prohibit probing on optprobe template code Masami Hiramatsu
2019-02-13  8:58   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:11 ` [PATCH -tip v3 02/10] x86/kprobes: Move trampoline code into RODATA Masami Hiramatsu
2019-02-13  8:59   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:12 ` [PATCH -tip v3 03/10] x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() Masami Hiramatsu
2019-02-13  9:00   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:12 ` [PATCH -tip v3 04/10] x86/kprobes: Prohibit probing on IRQ handlers directly Masami Hiramatsu
2019-02-13  9:00   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-03-25 21:23   ` [PATCH -tip v3 04/10] " Steven Rostedt
2019-03-26 14:50     ` Masami Hiramatsu
2019-03-26 15:17       ` Andrea Righi
2019-02-12 16:13 ` [PATCH -tip v3 05/10] kprobes: Search non-suffixed symbol in blacklist Masami Hiramatsu
2019-02-13  7:13   ` Ingo Molnar
2019-02-13  7:17     ` Ingo Molnar
2019-02-13 13:43       ` Steven Rostedt
2019-02-13 23:44       ` Masami Hiramatsu
2019-02-13  9:01   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:13 ` [PATCH -tip v3 06/10] kprobes: Prohibit probing on hardirq tracers Masami Hiramatsu
2019-02-13  9:02   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:14 ` [PATCH -tip v3 07/10] kprobes: Prohibit probing on preempt_check debug functions Masami Hiramatsu
2019-02-13  9:02   ` [tip:perf/core] kprobes: Prohibit probing on preemption checking " tip-bot for Masami Hiramatsu
2019-02-12 16:14 ` [PATCH -tip v3 08/10] kprobes: Prohibit probing on RCU debug routine Masami Hiramatsu
2019-02-13  9:03   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:15 ` [PATCH -tip v3 09/10] kprobes: Prohibit probing on lockdep functions Masami Hiramatsu
2019-02-13  9:03   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:15 ` [PATCH -tip v3 10/10] kprobes: Prohibit probing on bsearch() Masami Hiramatsu
2019-02-13  9:04   ` [tip:perf/core] " tip-bot for Andrea Righi

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).