From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753466AbdLVLio (ORCPT ); Fri, 22 Dec 2017 06:38:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:35444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750961AbdLVLii (ORCPT ); Fri, 22 Dec 2017 06:38:38 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 407F821921 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org From: Masami Hiramatsu To: Alexei Starovoitov , Josef Bacik Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ast@kernel.org, kernel-team@fb.com, daniel@iogearbox.net, linux-btrfs@vger.kernel.org, darrick.wong@oracle.com, mhiramat@kernel.org, Josef Bacik Subject: [RFC PATCH bpf-next 0/3] Separate error injection framework from kprobes Date: Fri, 22 Dec 2017 20:38:13 +0900 Message-Id: <151394269314.5598.6344820223613246849.stgit@devbox> X-Mailer: git-send-email 2.13.6 User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Josef and Alexei, Here are the patches which describe what I think more "natural" introduction of error injection APIs. Basically what I did on this series is to separate error injection from kprobes and put it on new error-injection small subsystem which is currently provide whitelists and just-return function stub. There are 2 main reasons why I separate it from kprobes. - kprobes users can modify execution path not only at error-injection whitelist functions but also other functions. I don't like to suggest user that such limitation is from kprobes itself. - This error injection information is also useful for ftrace (function-hook) and livepatch. It should not be limited by CONFIG_KPROBES. So I introduced CONFIG_FUNCTION_ERROR_INJECTION for this feature. This series also have some improvement suggestions. - [1/3] "kprobe override function" feature is not limited by ftrace-based kprobe, but also you can use it on sw-breakpoint based kprobe too. Also, you must check the kprobe is on the entry of function right before setting up the stackframe. - [2/3] If we store original instruction pointer and compare it with regs->ip, we don't need per-cpu bpf_kprobe_override. Also, reset_current_kprobe() and preempt_enable_no_resched() are no need to separate. Any thoughts? If it is good, I also add MAINTAINERS entry for this feature and add some testcases using kprobes and ftrace to inject error. (And maybe we also need a document how to use) BTW, it seems there are many error injection frameworks in lib/. We may also consider these distinctions. Thank you, --- Masami Hiramatsu (3): tracing/kprobe: bpf: Check error injectable event is on function entry tracing/kprobe: bpf: Compare instruction pointer with original one error-injection: Separate error-injection from kprobe arch/Kconfig | 2 arch/x86/Kconfig | 2 arch/x86/include/asm/error-injection.h | 12 ++ arch/x86/kernel/kprobes/ftrace.c | 14 -- arch/x86/lib/Makefile | 2 arch/x86/lib/error-inject.c | 19 +++ fs/btrfs/disk-io.c | 2 fs/btrfs/free-space-cache.c | 2 include/asm-generic/error-injection.h | 20 +++ include/asm-generic/vmlinux.lds.h | 14 +- include/linux/bpf.h | 12 -- include/linux/error-injection.h | 21 +++ include/linux/kprobes.h | 1 include/linux/module.h | 6 - kernel/kprobes.c | 163 -------------------------- kernel/module.c | 8 + kernel/trace/Kconfig | 4 - kernel/trace/bpf_trace.c | 9 + kernel/trace/trace_kprobe.c | 32 ++--- kernel/trace/trace_probe.h | 12 +- lib/Kconfig.debug | 4 + lib/Makefile | 1 lib/error-inject.c | 200 ++++++++++++++++++++++++++++++++ 23 files changed, 323 insertions(+), 239 deletions(-) create mode 100644 arch/x86/include/asm/error-injection.h create mode 100644 arch/x86/lib/error-inject.c create mode 100644 include/asm-generic/error-injection.h create mode 100644 include/linux/error-injection.h create mode 100644 lib/error-inject.c -- Signature