From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24784 invoked by alias); 19 Dec 2013 09:09:43 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 24772 invoked by uid 89); 19 Dec 2013 09:09:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail9.hitachi.co.jp Received: from mail9.hitachi.co.jp (HELO mail9.hitachi.co.jp) (133.145.228.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Dec 2013 09:09:40 +0000 Received: from mlsv8.hitachi.co.jp (unknown [133.144.234.166]) by mail9.hitachi.co.jp (Postfix) with ESMTP id C88A037C8B; Thu, 19 Dec 2013 18:09:37 +0900 (JST) Received: from mfilter04.hitachi.co.jp by mlsv8.hitachi.co.jp (8.13.1/8.13.1) id rBJ99bFn013286; Thu, 19 Dec 2013 18:09:37 +0900 Received: from vshuts02.hitachi.co.jp (vshuts02.hitachi.co.jp [10.201.6.84]) by mfilter04.hitachi.co.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id rBJ99ad1022745; Thu, 19 Dec 2013 18:09:37 +0900 Received: from gmml27.itg.hitachi.co.jp (unknown [158.213.165.130]) by vshuts02.hitachi.co.jp (Postfix) with ESMTP id 50A0C490060; Thu, 19 Dec 2013 18:09:36 +0900 (JST) Received: from kbuild-fedora.novalocal by gmml27.itg.hitachi.co.jp (AIX5.2/8.11.6p2/8.11.0) id rBJ99a28872050; Thu, 19 Dec 2013 18:09:36 +0900 Subject: [PATCH -tip v6 00/22] kprobes: introduce NOKPROBE_SYMBOL(), cleanup and fixes crash bugs To: Ingo Molnar From: Masami Hiramatsu Cc: linux-arch@vger.kernel.org, Ananth N Mavinakayanahalli , Sandeepa Prabhu , x86@kernel.org, lkml , "Steven Rostedt (Red Hat)" , systemtap@sourceware.org, "David S. Miller" Date: Thu, 19 Dec 2013 09:09:00 -0000 Message-ID: <20131219090353.14309.15496.stgit@kbuild-fedora.novalocal> User-Agent: StGit/0.16 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-q4/txt/msg00429.txt.bz2 Hi, Here is the version 6 of NOKPROBE_SYMBOL series. :) This includes small updates and introducing nokprobe_inline macro to prevent probing on the static/inlined small functions since NOKPROBE_SYMBOL will inhibit inlining by referring function address. This macro is more self-describing than normal __always_inline. (Thanks to Steven Rostedt!) This series also adds four new patches, the first is prohibiting probes on memset/memcpy since probing it freezes the kernel. The next is allowing kprobes on text_poke/hw_breakpoint handler which is not related to kprobes int3/debug handling path. And the third is removing preempt disable/enable in kprobes/x86 code. The last is original instruction recovery code for bad kprobes (Thanks to Ingo Molnar!) This recovery code is important to make the kprobes more robust. Currently, kprobes uses __kprobes annotation and internal symbol-name based blacklist to prohibit probing on some functions, because to probe those functions may cause an infinit recursive loop by int3/debug exceptions. However, current mechanisms have some problems especially from the view point of maintaining code; - __kprobes is easy to confuse the function is used by kprobes, despite it just means "no kprobe on it". - __kprobes moves functions to different section this will be not good for cache optimization. - symbol-name based solution is not good at all, since the symbol name easily be changed, and we cannot notice it. - it doesn't support functions in modules at all. Thus, I decided to introduce new NOKPROBE_SYMBOL macro for building an integrated kprobe blacklist. The new macro stores the address of the given symbols into _kprobe_blacklist section, and initialize the blacklist based on the address list at boottime. This is also applied for modules. When loading a module, kprobes finds the blacklist symbols in _kprobe_blacklist section in the module automatically. This series replaces all __kprobes on x86 and generic code with the NOKPROBE_SYMBOL() too. Although, the new blacklist still support old-style __kprobes by decoding .kprobes.text if exist, because it still be used on arch-dependent code except for x86. This series will fix the kernel crashable "qualitative" bugs of kprobes even with lockdep. But we still have "quantitative" issue which we are discussing on LKML. https://lkml.org/lkml/2013/12/3/788 I'd like to send another series for solving this "quantitative" issue. Changes from the previous: - [2/22] Introduce nokprobe_inline macro - [6/22] Prohibit probing on memset/memcpy - [11/22] Allow probing on text_poke/hw_breakpoint - [12/22] Use nokprobe_inline macro instead of __always_inline - [14/22] Ditto. - [21/22] Remove preempt disable/enable from kprobes/x86 - [22/22] Add emergency int3 recovery code Thank you, --- Masami Hiramatsu (22): kprobes: Prohibit probing on .entry.text code kprobes: Introduce NOKPROBE_SYMBOL() macro for blacklist [BUGFIX] kprobes/x86: Prohibit probing on debug_stack_* [BUGFIX] x86: Prohibit probing on native_set_debugreg/load_idt [BUGFIX] x86: Prohibit probing on thunk functions and restore [BUGFIX] x86: Prohibit probing on memcpy/memset kprobes/x86: Call exception handlers directly from do_int3/do_debug kprobes/x86: Allow probe on some kprobe preparation functions kprobes: Allow probe on some kprobe functions ftrace/kprobes: Allow probing on some preparation functions x86: Allow kprobes on text_poke/hw_breakpoint x86: Use NOKPROBE_SYMBOL() instead of __kprobes annotation kprobes: Use NOKPROBE_SYMBOL macro instead of __kprobes ftrace/kprobes: Use NOKPROBE_SYMBOL macro in ftrace notifier: Use NOKPROBE_SYMBOL macro in notifier sched: Use NOKPROBE_SYMBOL macro in sched kprobes: Show blacklist entries via debugfs kprobes: Support blacklist functions in module kprobes: Use NOKPROBE_SYMBOL() in sample modules kprobes/x86: Use kprobe_blacklist for .kprobes.text and .entry.text kprobes/x86: Remove unneeded preempt_disable/enable in interrupt handlers [RFC] kprobes/x86: Add emergency recovery process for bad kprobes Documentation/kprobes.txt | 24 +- arch/x86/include/asm/asm.h | 7 arch/x86/include/asm/fixmap.h | 7 arch/x86/include/asm/kprobes.h | 3 arch/x86/include/asm/paravirt.h | 7 arch/x86/include/asm/processor.h | 2 arch/x86/include/asm/special_insns.h | 4 arch/x86/include/asm/string_32.h | 6 arch/x86/include/asm/tlbflush.h | 6 arch/x86/include/asm/traps.h | 2 arch/x86/kernel/alternative.c | 3 arch/x86/kernel/apic/hw_nmi.c | 3 arch/x86/kernel/cpu/common.c | 4 arch/x86/kernel/cpu/perf_event.c | 3 arch/x86/kernel/cpu/perf_event_amd_ibs.c | 3 arch/x86/kernel/dumpstack.c | 9 - arch/x86/kernel/entry_32.S | 33 -- arch/x86/kernel/entry_64.S | 20 - arch/x86/kernel/hw_breakpoint.c | 5 arch/x86/kernel/kprobes/core.c | 193 +++++++----- arch/x86/kernel/kprobes/ftrace.c | 17 + arch/x86/kernel/kprobes/opt.c | 32 +- arch/x86/kernel/kvm.c | 4 arch/x86/kernel/nmi.c | 18 + arch/x86/kernel/paravirt.c | 6 arch/x86/kernel/traps.c | 30 +- arch/x86/lguest/boot.c | 1 arch/x86/lib/memcpy_32.c | 2 arch/x86/lib/memcpy_64.S | 4 arch/x86/lib/memset_64.S | 3 arch/x86/lib/thunk_32.S | 3 arch/x86/lib/thunk_64.S | 3 arch/x86/mm/fault.c | 28 +- arch/x86/mm/pgtable.c | 3 include/asm-generic/vmlinux.lds.h | 9 + include/linux/compiler.h | 2 include/linux/kprobes.h | 31 ++ include/linux/module.h | 5 kernel/kprobes.c | 466 +++++++++++++++++++----------- kernel/module.c | 6 kernel/notifier.c | 22 + kernel/sched/core.c | 7 kernel/trace/trace_event_perf.c | 5 kernel/trace/trace_kprobe.c | 53 ++- kernel/trace/trace_probe.c | 78 +++-- kernel/trace/trace_probe.h | 4 samples/kprobes/jprobe_example.c | 1 samples/kprobes/kprobe_example.c | 3 samples/kprobes/kretprobe_example.c | 2 tools/perf/bench/mem-memcpy-x86-64-asm.S | 1 tools/perf/bench/mem-memset-x86-64-asm.S | 1 51 files changed, 747 insertions(+), 447 deletions(-) -- Masami HIRAMATSU IT Management Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com