Re: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Masami Hiramatsu
On Mon, 12 Mar 2018 11:44:21 +0100 Daniel Borkmann wrote: > Hi Masami, > > On 03/12/2018 11:27 AM, Masami Hiramatsu wrote: > > On Mon, 12 Mar 2018 19:00:49 +0900 > > Masami Hiramatsu wrote: > > > >> Since the kprobe which was optimized by jump can not

Re: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Masami Hiramatsu
On Mon, 12 Mar 2018 19:00:49 +0900 Masami Hiramatsu wrote: > Since the kprobe which was optimized by jump can not change > the execution path, the kprobe for error-injection must not > be optimized. To prohibit it, set a dummy post-handler as > officially stated in Documentation

[BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Masami Hiramatsu
ction framework") Signed-off-by: Masami Hiramatsu --- kernel/fail_function.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/kernel/fail_function.c b/kernel/fail_function.c index 21b0122cb39c..1d5632d8bbcc 100644 --- a/kernel/fail_function.c +++ b/kernel/fail_function.c @@ -1

Re: [PATCH bpf-next v5 5/5] error-injection: Support fault injection framework

2018-01-13 Thread Masami Hiramatsu
On Sat, 13 Jan 2018 22:28:29 +0900 Akinobu Mita wrote: > 2018-01-13 2:56 GMT+09:00 Masami Hiramatsu : > > Support in-kernel fault-injection framework via debugfs. > > This allows you to inject a conditional error to specified > > function using debugfs interfaces. > >

[PATCH bpf-next v5 3/5] error-injection: Separate error-injection from kprobe

2018-01-12 Thread Masami Hiramatsu
eature for kprobe or ftrace etc. Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik --- Changes in v3: - Fix a build error for asmlinkage on i386 by including compiler.h - Fix "CONFIG_FUNCTION_ERROR_INJECT" typo. - Separate CONFIG_MODULES dependent code - Add CONFIG_KP

[PATCH bpf-next v5 5/5] error-injection: Support fault injection framework

2018-01-12 Thread Masami Hiramatsu
devices: 1 Devices: IDSIZE PATH 1 1001.00MiB /dev/loop2 mount: mount /dev/loop2 on /opt/tmpmnt failed: Cannot allocate memory SUCCESS! === Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik --- Changes in v3: - Check and adjust error value for

[PATCH bpf-next v5 4/5] error-injection: Add injectable error types

2018-01-12 Thread Masami Hiramatsu
/debug/error_injection/list open_ctree [btrfs]ERRNO io_ctl_init [btrfs] ERRNO Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik --- fs/btrfs/disk-io.c|2 +- fs/btrfs/free-space-cache.c |2 +- include/asm-generic/error-injection.h | 23

[PATCH bpf-next v5 2/5] tracing/kprobe: bpf: Compare instruction pointer with original one

2018-01-12 Thread Masami Hiramatsu
Compare instruction pointer with original one on the stack instead using per-cpu bpf_kprobe_override flag. This patch also consolidates reset_current_kprobe() and preempt_enable_no_resched() blocks. Those can be done in one place. Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik

[PATCH bpf-next v5 1/5] tracing/kprobe: bpf: Check error injectable event is on function entry

2018-01-12 Thread Masami Hiramatsu
value, that operation must be done before the target function starts making stackframe. As a side effect, bpf error injection is no need to depend on function-tracer. It can work with sw-breakpoint based kprobe events too. Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik --- Changes in v3

[PATCH bpf-next v5 0/5] Separate error injection table from kprobes

2018-01-12 Thread Masami Hiramatsu
within_error_injection returns false always. - [5/5] Update to support multiple function error injection. Thank you, --- Masami Hiramatsu (5): tracing/kprobe: bpf: Check error injectable event is on function entry tracing/kprobe: bpf: Compare instruction pointer with original one

Re: [PATCH bpf-next v4 5/5] error-injection: Support fault injection framework

2018-01-11 Thread Masami Hiramatsu
On Thu, 11 Jan 2018 23:44:57 +0900 Akinobu Mita wrote: > 2018-01-11 9:51 GMT+09:00 Masami Hiramatsu : > > Support in-kernel fault-injection framework via debugfs. > > This allows you to inject a conditional error to specified > > function using debugfs interfaces. > >

[PATCH bpf-next v4 5/5] error-injection: Support fault injection framework

2018-01-10 Thread Masami Hiramatsu
devices: 1 Devices: IDSIZE PATH 1 1001.00MiB /dev/loop2 mount: mount /dev/loop2 on /opt/tmpmnt failed: Cannot allocate memory SUCCESS! === Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik --- Changes in v3: - Check and adjust error value for

[PATCH bpf-next v4 4/5] error-injection: Add injectable error types

2018-01-10 Thread Masami Hiramatsu
/debug/error_injection/list open_ctree [btrfs]ERRNO io_ctl_init [btrfs] ERRNO Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik --- fs/btrfs/disk-io.c|2 +- fs/btrfs/free-space-cache.c |2 +- include/asm-generic/error-injection.h | 23

[PATCH bpf-next v4 3/5] error-injection: Separate error-injection from kprobe

2018-01-10 Thread Masami Hiramatsu
eature for kprobe or ftrace etc. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Fix a build error for asmlinkage on i386 by including compiler.h - Fix "CONFIG_FUNCTION_ERROR_INJECT" typo. - Separate CONFIG_MODULES dependent code - Add CONFIG_KPROBES dependency for ar

[PATCH bpf-next v4 2/5] tracing/kprobe: bpf: Compare instruction pointer with original one

2018-01-10 Thread Masami Hiramatsu
Compare instruction pointer with original one on the stack instead using per-cpu bpf_kprobe_override flag. This patch also consolidates reset_current_kprobe() and preempt_enable_no_resched() blocks. Those can be done in one place. Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik

[PATCH bpf-next v4 1/5] tracing/kprobe: bpf: Check error injectable event is on function entry

2018-01-10 Thread Masami Hiramatsu
value, that operation must be done before the target function starts making stackframe. As a side effect, bpf error injection is no need to depend on function-tracer. It can work with sw-breakpoint based kprobe events too. Signed-off-by: Masami Hiramatsu Reviewed-by: Josef Bacik --- Changes in v3

[PATCH bpf-next v4 0/5] Separate error injection table from kprobes

2018-01-10 Thread Masami Hiramatsu
/858176/ Changes in v3: - [3/5] Change error-injection.h including points to each file which uses ALLOW_ERROR_INJECTION instead of bpf.h - Add Reviewed-by from Josef Bacik except [3/5] Thank you, --- Masami Hiramatsu (5): tracing/kprobe: bpf: Check error injectable event is on function

Re: [PATCH bpf-next v3 3/5] error-injection: Separate error-injection from kprobe

2018-01-10 Thread Masami Hiramatsu
On Wed, 10 Jan 2018 10:36:15 -0500 Josef Bacik wrote: > On Wed, Jan 10, 2018 at 07:18:05PM +0900, Masami Hiramatsu wrote: > > Since error-injection framework is not limited to be used > > by kprobes, nor bpf. Other kernel subsystems can use it > > freely for checking safene

[PATCH bpf-next v3 2/5] tracing/kprobe: bpf: Compare instruction pointer with original one

2018-01-10 Thread Masami Hiramatsu
Compare instruction pointer with original one on the stack instead using per-cpu bpf_kprobe_override flag. This patch also consolidates reset_current_kprobe() and preempt_enable_no_resched() blocks. Those can be done in one place. Signed-off-by: Masami Hiramatsu --- kernel/trace/bpf_trace.c

[PATCH bpf-next v3 3/5] error-injection: Separate error-injection from kprobe

2018-01-10 Thread Masami Hiramatsu
eature for kprobe or ftrace etc. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Fix a build error for asmlinkage on i386 by including compiler.h - Fix "CONFIG_FUNCTION_ERROR_INJECT" typo. - Separate CONFIG_MODULES dependent code - Add CONFIG_KPROBES dependency for ar

[PATCH bpf-next v3 4/5] error-injection: Add injectable error types

2018-01-10 Thread Masami Hiramatsu
/debug/error_injection/list open_ctree [btrfs]ERRNO io_ctl_init [btrfs] ERRNO Signed-off-by: Masami Hiramatsu --- fs/btrfs/disk-io.c|2 +- fs/btrfs/free-space-cache.c |2 +- include/asm-generic/error-injection.h | 23 +++--- include

[PATCH bpf-next v3 5/5] error-injection: Support fault injection framework

2018-01-10 Thread Masami Hiramatsu
devices: 1 Devices: IDSIZE PATH 1 1001.00MiB /dev/loop2 mount: mount /dev/loop2 on /opt/tmpmnt failed: Cannot allocate memory SUCCESS! === Signed-off-by: Masami Hiramatsu --- Changes in v3: - Check and adjust error value for each target function

[PATCH bpf-next v3 1/5] tracing/kprobe: bpf: Check error injectable event is on function entry

2018-01-10 Thread Masami Hiramatsu
value, that operation must be done before the target function starts making stackframe. As a side effect, bpf error injection is no need to depend on function-tracer. It can work with sw-breakpoint based kprobe events too. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Move

[PATCH bpf-next v3 0/5] Separate error injection table from kprobes

2018-01-10 Thread Masami Hiramatsu
n late_initcall stage. - [4/5] Newly added - [5/5] Check and adjust error value for each target function and add more documents and example. Thank you, --- Masami Hiramatsu (5): tracing/kprobe: bpf: Check error injectable event is on function entry tracing/kprobe: bpf: Co

Re: [RFC PATCH bpf-next v2 0/4] Separate error injection table from kprobes

2018-01-08 Thread Masami Hiramatsu
On Thu, 4 Jan 2018 11:07:16 -0500 Josef Bacik wrote: > On Tue, Dec 26, 2017 at 04:46:28PM +0900, Masami Hiramatsu wrote: > > Hi Josef and Alexei, > > > > Here are the 2nd version of patches to moving error injection > > table from kprobes. In this series I did a small

Re: [RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry

2018-01-08 Thread Masami Hiramatsu
On Sun, 7 Jan 2018 19:01:57 -0800 Alexei Starovoitov wrote: > On 12/29/17 12:20 AM, Masami Hiramatsu wrote: > >> Please run Josef's test in the !ftrace setup. > > Yes, I'll add the result of the test case. > > if Josef's test is passing in !ftrace config,

Re: [RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry

2017-12-29 Thread Masami Hiramatsu
On Thu, 28 Dec 2017 17:03:24 -0800 Alexei Starovoitov wrote: > On 12/28/17 12:20 AM, Masami Hiramatsu wrote: > > On Wed, 27 Dec 2017 20:32:07 -0800 > > Alexei Starovoitov wrote: > > > >> On 12/27/17 8:16 PM, Steven Rostedt wrote: > >>> On Wed, 27 Dec 20

Re: [RFC PATCH bpf-next v2 4/4] error-injection: Support fault injection framework

2017-12-28 Thread Masami Hiramatsu
On Thu, 28 Dec 2017 17:11:31 -0800 Alexei Starovoitov wrote: > On 12/27/17 11:51 PM, Masami Hiramatsu wrote: > > > > Then what happen if the user set invalid retval to those functions? > > even if we limit the injectable functions, it can cause a problem, > > &g

Re: [RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry

2017-12-28 Thread Masami Hiramatsu
ll cover this situation. > Probably only special .config is needed to disable ftrace, so > "kprobe on entry but not ftrace" check will kick in. Right. If you need to test it, you can run Josef's test case without CONFIG_DYNAMIC_FTRACE. > But I didn't get an impression that this

Re: [RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry

2017-12-27 Thread Masami Hiramatsu
On Wed, 27 Dec 2017 19:45:42 -0800 Alexei Starovoitov wrote: > On 12/27/17 6:34 PM, Masami Hiramatsu wrote: > > On Wed, 27 Dec 2017 14:46:24 -0800 > > Alexei Starovoitov wrote: > > > >> On 12/26/17 9:56 PM, Masami Hiramatsu wrote: > >>> On Tu

Re: [RFC PATCH bpf-next v2 4/4] error-injection: Support fault injection framework

2017-12-27 Thread Masami Hiramatsu
On Wed, 27 Dec 2017 19:49:28 -0800 Alexei Starovoitov wrote: > On 12/27/17 5:38 PM, Masami Hiramatsu wrote: > > On Wed, 27 Dec 2017 14:49:46 -0800 > > Alexei Starovoitov wrote: > > > >> On 12/27/17 12:09 AM, Masami Hiramatsu wrote: > >>> On Tu

Re: [RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry

2017-12-27 Thread Masami Hiramatsu
On Wed, 27 Dec 2017 14:46:24 -0800 Alexei Starovoitov wrote: > On 12/26/17 9:56 PM, Masami Hiramatsu wrote: > > On Tue, 26 Dec 2017 17:57:32 -0800 > > Alexei Starovoitov wrote: > > > >> On Tue, Dec 26, 2017 at 04:46:59PM +0900, Masami Hiramatsu wrote: > >>

Re: [RFC PATCH bpf-next v2 4/4] error-injection: Support fault injection framework

2017-12-27 Thread Masami Hiramatsu
On Wed, 27 Dec 2017 14:49:46 -0800 Alexei Starovoitov wrote: > On 12/27/17 12:09 AM, Masami Hiramatsu wrote: > > On Tue, 26 Dec 2017 18:12:56 -0800 > > Alexei Starovoitov wrote: > > > >> On Tue, Dec 26, 2017 at 04:48:25PM +0900, Masami Hiramatsu wrote: > >

Re: [RFC PATCH bpf-next v2 4/4] error-injection: Support fault injection framework

2017-12-27 Thread Masami Hiramatsu
On Tue, 26 Dec 2017 18:12:56 -0800 Alexei Starovoitov wrote: > On Tue, Dec 26, 2017 at 04:48:25PM +0900, Masami Hiramatsu wrote: > > Support in-kernel fault-injection framework via debugfs. > > This allows you to inject a conditional error to specified > > function usi

Re: [RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry

2017-12-26 Thread Masami Hiramatsu
On Tue, 26 Dec 2017 17:57:32 -0800 Alexei Starovoitov wrote: > On Tue, Dec 26, 2017 at 04:46:59PM +0900, Masami Hiramatsu wrote: > > Check whether error injectable event is on function entry or not. > > Currently it checks the event is ftrace-based kprobes or not, > >

[RFC PATCH bpf-next v2 4/4] error-injection: Support fault injection framework

2017-12-25 Thread Masami Hiramatsu
Support in-kernel fault-injection framework via debugfs. This allows you to inject a conditional error to specified function using debugfs interfaces. Signed-off-by: Masami Hiramatsu --- Documentation/fault-injection/fault-injection.txt |5 + kernel/Makefile

[RFC PATCH bpf-next v2 3/4] error-injection: Separate error-injection from kprobe

2017-12-25 Thread Masami Hiramatsu
eature for kprobe or ftrace etc. Signed-off-by: Masami Hiramatsu --- Changes in v2: - Fix the override function name to override_function_with_return() - Show only function name in the list, user don't have to care about it's size, since function override only happens at the entr

[RFC PATCH bpf-next v2 2/4] tracing/kprobe: bpf: Compare instruction pointer with original one

2017-12-25 Thread Masami Hiramatsu
Compare instruction pointer with original one on the stack instead using per-cpu bpf_kprobe_override flag. This patch also consolidates reset_current_kprobe() and preempt_enable_no_resched() blocks. Those can be done in one place. Signed-off-by: Masami Hiramatsu --- kernel/trace/bpf_trace.c

[RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry

2017-12-25 Thread Masami Hiramatsu
value, that operation must be done before the target function starts making stackframe. As a side effect, bpf error injection is no need to depend on function-tracer. It can work with sw-breakpoint based kprobe events too. Signed-off-by: Masami Hiramatsu --- kernel/trace/Kconfig|2

[RFC PATCH bpf-next v2 0/4] Separate error injection table from kprobes

2017-12-25 Thread Masami Hiramatsu
TW, I think we should add an error-range description in ALLOW_ERROR_INJECTION() macro. If user sets a success return value and override it by mistake, caller must break data or cause kernel panic. Thank you, --- Masami Hiramatsu (4): tracing/kprobe: bpf: Check error injectable event is on fun

[RFC PATCH bpf-next 3/3] error-injection: Separate error-injection from kprobe

2017-12-22 Thread Masami Hiramatsu
eature for kprobe or ftrace etc. Signed-off-by: Masami Hiramatsu --- 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

[RFC PATCH bpf-next 2/3] tracing/kprobe: bpf: Compare instruction pointer with original one

2017-12-22 Thread Masami Hiramatsu
Compare instruction pointer with original one on the stack instead using per-cpu bpf_kprobe_override flag. This patch also consolidates reset_current_kprobe() and preempt_enable_no_resched() blocks. Those can be done in one place. Signed-off-by: Masami Hiramatsu --- kernel/trace/bpf_trace.c

[RFC PATCH bpf-next 1/3] tracing/kprobe: bpf: Check error injectable event is on function entry

2017-12-22 Thread Masami Hiramatsu
value, that operation must be done before the target function starts making stackframe. As a side effect, bpf error injection is no need to depend on function-tracer. It can work with sw-breakpoint based kprobe events too. Signed-off-by: Masami Hiramatsu --- kernel/trace/Kconfig|2

[RFC PATCH bpf-next 0/3] Separate error injection framework from kprobes

2017-12-22 Thread Masami Hiramatsu
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:

Re: [PATCH v10 1/5] add infrastructure for tagging functions as error injectable

2017-12-20 Thread Masami Hiramatsu
void arm_all_kprobes(void) > { > struct hlist_head *head; > @@ -2548,6 +2706,11 @@ static int __init debugfs_kprobe_init(void) > if (!file) > goto error; > > + file = debugfs_create_file("error_injection_list", 0444, dir, NULL, > +

Re: [PATCH v10 1/5] add infrastructure for tagging functions as error injectable

2017-12-19 Thread Masami Hiramatsu
On Tue, 19 Dec 2017 18:14:17 -0800 Alexei Starovoitov wrote: > On 12/18/17 10:29 PM, Masami Hiramatsu wrote: > >> > >> +#if defined(__KERNEL__) && !defined(__ASSEMBLY__) > >> +#ifdef CONFIG_BPF_KPROBE_OVERRIDE > > > > BTW, CONFIG_BPF_KPROB

Re: [PATCH v10 3/5] bpf: add a bpf_override_function helper

2017-12-18 Thread Masami Hiramatsu
On Mon, 18 Dec 2017 16:09:30 +0100 Daniel Borkmann wrote: > On 12/18/2017 10:51 AM, Masami Hiramatsu wrote: > > On Fri, 15 Dec 2017 14:12:54 -0500 > > Josef Bacik wrote: > >> From: Josef Bacik > >> > >> Error injection is sloppy and very ad-hoc. BPF

Re: [PATCH v10 1/5] add infrastructure for tagging functions as error injectable

2017-12-18 Thread Masami Hiramatsu
bugfs_kprobe_ei_ops = { > + .open = kprobe_ei_open, > + .read = seq_read, > + .llseek = seq_lseek, > + .release= seq_release, > +}; > + > static void arm_all_kprobes(void) > { > struct hlist_head *head; > @@ -2548,6 +2706,11 @@ static int __init debugfs_kpr

Re: [PATCH v10 3/5] bpf: add a bpf_override_function helper

2017-12-18 Thread Masami Hiramatsu
race/trace_probe.h > @@ -252,6 +252,8 @@ struct symbol_cache; > unsigned long update_symbol_cache(struct symbol_cache *sc); > void free_symbol_cache(struct symbol_cache *sc); > struct symbol_cache *alloc_symbol_cache(const char *sym, long offset); > +int trace_kprobe_ftrace(struc

Re: [PATCH v10 1/5] add infrastructure for tagging functions as error injectable

2017-12-18 Thread Masami Hiramatsu
, > +}; > + > static void arm_all_kprobes(void) > { > struct hlist_head *head; > @@ -2548,6 +2706,11 @@ static int __init debugfs_kprobe_init(void) > if (!file) > goto error; > > + file = debugfs_create_file("error_injection_list", 0444, dir, NULL, > + &debugfs_kprobe_ei_ops); > + if (!file) > + goto error; > + > return 0; > > error: > diff --git a/kernel/module.c b/kernel/module.c > index dea01ac9cb74..bd695bfdc5c4 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -3118,7 +3118,11 @@ static int find_module_sections(struct module *mod, > struct load_info *info) >sizeof(*mod->ftrace_callsites), >&mod->num_ftrace_callsites); > #endif > - > +#ifdef CONFIG_BPF_KPROBE_OVERRIDE > + mod->kprobe_ei_funcs = section_objs(info, "_kprobe_error_inject_list", > + sizeof(*mod->kprobe_ei_funcs), > + &mod->num_kprobe_ei_funcs); > +#endif > mod->extable = section_objs(info, "__ex_table", > sizeof(*mod->extable), &mod->num_exentries); > > -- > 2.7.5 > -- Masami Hiramatsu -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH v9 0/5] Add the ability to do BPF directed error injection

2017-12-13 Thread Masami Hiramatsu
d1c958 EFLAGS: 0202 ORIG_RAX: > > > > 00a5 > > > > [ 1847.813615] RAX: ffda RBX: 00007f6ebefba63a RCX: > > > > 7f6ebecc1b5a > > > > [ 1847.814302] RDX: 00bfd010 RSI: 00bfa230 RDI: > > > > 0