Re: [PATCHv2 RFC bpf-next 0/7] bpf: Add support for ftrace probe

2021-04-19 Thread Masami Hiramatsu
On Fri, 16 Apr 2021 12:48:34 -0400 Steven Rostedt wrote: > On Sat, 17 Apr 2021 00:03:04 +0900 > Masami Hiramatsu wrote: > > > > Anyway, IIRC, Masami wasn't sure that the full regs was ever needed for > > > the > > > return (who cares about the r

Re: [PATCHv2 RFC bpf-next 0/7] bpf: Add support for ftrace probe

2021-04-16 Thread Masami Hiramatsu
work for both > > > BPF and ftrace. > > > > Absolutely, ultimately for users it doesn't matter what specific > > mechanism is used under the cover. It just seemed like BPF trampoline > > has all the useful tracing features (entry IP and input arguments in > > fexit) already and is just mostly missing a quick batch attach API. If > > we can get the same from ftrace, all the better. > > Let me pull these patches out again, and see what we can do. Since then, > I've added the code that lets function tracer save parameters and the > stack, and function graph can use that as well. > > > -- Steve -- Masami Hiramatsu

Re: UBSAN: array-index-out-of-bounds in arch_uprobe_analyze_insn

2020-12-01 Thread Masami Hiramatsu
eport.txt?x=1597348d90 > > console output: https://syzkaller.appspot.com/x/log.txt?x=1197348d90 > > kernel config: https://syzkaller.appspot.com/x/.config?x=b12e84189082991c > > dashboard link: https://syzkaller.appspot.com/bug?extid=9b64b619f10f19d19a7c > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1573a8ad90 > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=164ee6c590 > > > > Reported-by: syzbot+9b64b619f10f19d19...@syzkaller.appspotmail.com > > Fixes: 4b2bd5fec007 ("proc: fix timerslack_ns CAP_SYS_NICE check when > > adjusting self") > > > > For information about bisection process see: https://goo.gl/tpsmEJ#bisection > > -- > Kees Cook -- Masami Hiramatsu

Re: realtek PHY commit bbc4d71d63549 causes regression

2020-10-18 Thread Masami Hiramatsu
networking. (These boxes are often used headless, so this can be > annoying) > > > [0] > http://snapshots.linaro.org/components/kernel/leg-96boards-developerbox-edk2/83/ -- Masami Hiramatsu

Re: [PATCH] kprobes: fix compiler warning for !CONFIG_KPROBES_ON_FTRACE

2020-08-05 Thread Masami Hiramatsu
.auug.org.au > > Reported-by: Stephen Rothwell > Fixes: 0cb2f1372baa ("kprobes: Fix NULL pointer dereference at > kprobe_ftrace_handler") > Signed-off-by: Muchun Song Looks good to me. Acked-by: Masami Hiramatsu Thank you! > --- > kernel/kprobes.c | 17 +++

Re: [PATCH] kprobes: fix NULL pointer dereference at kprobe_ftrace_handler

2020-08-03 Thread Masami Hiramatsu
NE but not disarm the kprobe in the step 4). > > The step 5) also do not disarm the kprobe when unregister kprobe. So > > we do not remove the ip from the filter. In this case, when the module > > loads again in the step 6), we will replace the code to ftrace_caller > > vi

Re: [PATCH 4/5] kprobes: Do not expose probe addresses to non-CAP_SYSLOG

2020-07-10 Thread Masami Hiramatsu
On Thu, 2 Jul 2020 16:26:37 -0700 Kees Cook wrote: > The kprobe show() functions were using "current"'s creds instead > of the file opener's creds for kallsyms visibility. Fix to use > seq_file->file->f_cred. This looks good to me. Acked-by: Masam

Re: clean up and streamline probe_kernel_* and friends v4

2020-05-21 Thread Masami Hiramatsu
to probe_kernel_read_allowed > - document the -ERANGE return value This series looks good to me. Reviewed-by: Masami Hiramatsu for this series. Thank you! > > Changes since v2: > - rebased on 5.7-rc6 with the bpf trace format string changes > - rename arch_kernel_read to __

Re: [PATCH 14/23] tracing/kprobes: handle mixed kernel/userspace probes better

2020-05-21 Thread Masami Hiramatsu
s looks good to me. Acked-by: Masami Hiramatsu Thank you! > Signed-off-by: Christoph Hellwig > --- > kernel/trace/trace_kprobe.c | 72 ++--- > 1 file changed, 43 insertions(+), 29 deletions(-) > > diff --git a/kernel/trace/trace_kprobe.c

Re: [PATCH 13/20] maccess: always use strict semantics for probe_kernel_read

2020-05-20 Thread Masami Hiramatsu
(unsigned long)addr < TASK_SIZE) { return strnlen_user_nofault((__force u8 __user *)addr, MAX_STRING_SIZE); do { ret = probe_kernel_read(&c, (u8 *)addr + len, 1); len++; } while (c && ret == 0 && len < MAX_STRING_SIZE);

Re: [PATCH 20/20] maccess: return -ERANGE when copy_from_kernel_nofault_allowed fails

2020-05-20 Thread Masami Hiramatsu
On Tue, 19 May 2020 15:44:49 +0200 Christoph Hellwig wrote: > Allow the callers to distinguish a real unmapped address vs a range > that can't be probed. > > Suggested-by: Masami Hiramatsu > Signed-off-by: Christoph Hellwig Hi Christoph, Can you also update the kerneldo

Re: [PATCH 14/18] maccess: allow architectures to provide kernel probing directly

2020-05-15 Thread Masami Hiramatsu
eturn -EFAULT; > +} > +#else /* HAVE_ARCH_PROBE_KERNEL */ > /** > * probe_kernel_read(): safely attempt to read from kernel-space > * @dst: pointer to the buffer that shall take the data > @@ -114,6 +189,7 @@ long strncpy_from_kernel_nofault(char *dst, const void > *unsafe_addr, long count) > > return ret ? -EFAULT : src - unsafe_addr; > } > +#endif /* HAVE_ARCH_PROBE_KERNEL */ > > /** > * probe_user_read(): safely attempt to read from a user-space location > -- > 2.26.2 > -- Masami Hiramatsu

Re: [PATCH bpf 1/3] bpf: restrict bpf_probe_read{,str}() only to archs where they work

2020-05-14 Thread Masami Hiramatsu
ey are working in their current form. Therefore, > move this behind a CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE and > have x86, arm64, arm select it (other archs supporting it can follow-up > on it as well). > > Suggested-by: Linus Torvalds > Signed-off-by: Daniel Borkmann

Re: [PATCH 11/18] maccess: remove strncpy_from_unsafe

2020-05-14 Thread Masami Hiramatsu
On Wed, 13 May 2020 19:43:24 -0700 Linus Torvalds wrote: > On Wed, May 13, 2020 at 6:00 PM Masami Hiramatsu wrote: > > > > > But we should likely at least disallow it entirely on platforms where > > > we really can't - or pick one hardcoded choice. On sparc, yo

Re: [PATCH 10/18] maccess: unify the probe kernel arch hooks

2020-05-13 Thread Masami Hiramatsu
= get_fs(); > > + if (!probe_kernel_read_allowed(dst, src, size, strict)) > + return -EFAULT; Could you make this return -ERANGE instead of -EFAULT so that the caller can notice that the address might be user space? Thank you, -- Masami Hiramatsu

Re: [PATCH 11/18] maccess: remove strncpy_from_unsafe

2020-05-13 Thread Masami Hiramatsu
On Wed, 13 May 2020 16:59:40 -0700 Linus Torvalds wrote: > On Wed, May 13, 2020 at 4:21 PM Masami Hiramatsu wrote: > > > > > > For trace_kprobe.c current order (kernel -> user fallback) is preferred > > because it has another function dedicated for user memory.

Re: [PATCH 11/18] maccess: remove strncpy_from_unsafe

2020-05-13 Thread Masami Hiramatsu
lway > > try the user copy first, which seems odd. > > > > I'd really like to here from the bpf folks what the expected use case > > is here, and if the typical argument is kernel or user memory. > > It's used for both. Given this is enabled on pretty much all program types, my > assumption would be that usage is still more often on kernel memory than user > one. For trace_kprobe.c current order (kernel -> user fallback) is preferred because it has another function dedicated for user memory. Thank you, -- Masami Hiramatsu

Re: [PATCH 11/15] maccess: remove strncpy_from_unsafe

2020-05-10 Thread Masami Hiramatsu
p eventually. > > Signed-off-by: Christoph Hellwig This looks good to me. Reviewed-by: Masami Hiramatsu Thank you, > --- > include/linux/uaccess.h | 1 - > kernel/trace/bpf_trace.c| 40 ++--- > kernel/trace/trace_kprobe.c | 5 - >

Re: [PATCH 12/15] maccess: always use strict semantics for probe_kernel_read

2020-05-10 Thread Masami Hiramatsu
On Mon, 11 May 2020 14:05:36 +0900 Masami Hiramatsu wrote: > Hi Christoph, > > At first, thank you for your work on cleaning up these functions! > > On Wed, 6 May 2020 08:22:20 +0200 > Christoph Hellwig wrote: > > > Except for historical confusion in the kpro

Re: [PATCH 12/15] maccess: always use strict semantics for probe_kernel_read

2020-05-10 Thread Masami Hiramatsu
robe_kernel_read_allowed(dst, src, size, strict)) > + if (!probe_kernel_read_allowed(dst, src, size)) > return -EFAULT; > > set_fs(KERNEL_DS); > @@ -73,6 +45,7 @@ static long __probe_kernel_read(void *dst, const void *src, > size_t size, > return -EFAULT; > return 0; > } > +EXPORT_SYMBOL_GPL(probe_kernel_read); > > /** > * probe_user_read(): safely attempt to read from a user-space location > @@ -180,7 +153,7 @@ long strncpy_from_kernel_unsafe(char *dst, const void > *unsafe_addr, long count) > > if (unlikely(count <= 0)) > return 0; > - if (!probe_kernel_read_allowed(dst, unsafe_addr, count, true)) > + if (!probe_kernel_read_allowed(dst, unsafe_addr, count)) > return -EFAULT; > > set_fs(KERNEL_DS); > -- > 2.26.2 > -- Masami Hiramatsu

[RFC PATCH v2 2/3] arm64: kprobes: Support nested kprobes

2020-05-08 Thread Masami Hiramatsu
=> el0_svc_common.constprop.3 => do_el0_svc => el0_sync_handler => el0_sync This shows brk_handler is nested. Note that this also improve unrecoverable message to show nested probes too. Signed-off-by: Masami Hiramatsu --- Changes in v2: - Dump nested kprobes when

[RFC PATCH v2 1/3] x86/kprobes: Support nested kprobes

2020-05-08 Thread Masami Hiramatsu
s_execve => do_syscall_64 => entry_SYSCALL_64_after_hwframe This shows int3 is nested. Note that this also improve unrecoverable message to show nested probes too. Signed-off-by: Masami Hiramatsu --- Changes in v2: - Fix a build error in kprobes on ftrace. - Dump nested kprobes whe

[RFC PATCH v2 3/3] arm: kprobes: Support nested kprobes

2020-05-08 Thread Masami Hiramatsu
be_trap_handler => do_undefinstr => __und_svc_finish => vfs_read => sys_read => ret_fast_syscall The trap handler is nested correctly. Note that this also improve unrecoverable message to show nested probes too. Signed-off-by: Masami Hiramatsu --- Changes in v2: - Dump nested kp

[RFC PATCH v2 0/3] kprobes: Support nested kprobes

2020-05-08 Thread Masami Hiramatsu
ggr_pre_handler => kprobe_int3_handler => do_int3 => int3 => vfs_read => load_elf_phdrs => load_elf_binary => search_binary_handler.part.0 => __do_execve_file.isra.0 => __x64_sys_execve => do_syscall_64 => entry_SYSCALL_64_after_hwframe

Re: [RFC PATCH 1/3] x86/kprobes: Support nested kprobes

2020-05-07 Thread Masami Hiramatsu
On Thu, 7 May 2020 18:59:55 +0900 Masami Hiramatsu wrote: > Make kprobes to accept 1-level nesting instead of > diff --git a/arch/x86/kernel/kprobes/ftrace.c > b/arch/x86/kernel/kprobes/ftrace.c > index 681a4b36e9bb..b695c2e118f8 100644 > --- a/arch/x86/kernel/kprobes/ftrace.c &

[RFC PATCH 0/3] kprobes: Support nested kprobes

2020-05-07 Thread Masami Hiramatsu
er.part.0 => __do_execve_file.isra.0 => __x64_sys_execve => do_syscall_64 => entry_SYSCALL_64_after_hwframe So we can see the kprobe can be nested. Thank you, --- Masami Hiramatsu (3): x86/kprobes: Support nested kprobes arm64: kprobes: Support nested kprobe

[RFC PATCH 3/3] arm: kprobes: Support nested kprobes

2020-05-07 Thread Masami Hiramatsu
be_trap_handler => do_undefinstr => __und_svc_finish => vfs_read => sys_read => ret_fast_syscall The trap handler is nested correctly. Signed-off-by: Masami Hiramatsu --- arch/arm/include/asm/kprobes.h|5 ++ arch/arm/probes/kprobes/core.c| 79 ++

[RFC PATCH 2/3] arm64: kprobes: Support nested kprobes

2020-05-07 Thread Masami Hiramatsu
=> el0_svc_common.constprop.3 => do_el0_svc => el0_sync_handler => el0_sync This shows brk_handler is nested. Signed-off-by: Masami Hiramatsu --- arch/arm64/include/asm/kprobes.h |5 ++ arch/arm64/kernel/probes/kprobes.c | 75 2

[RFC PATCH 1/3] x86/kprobes: Support nested kprobes

2020-05-07 Thread Masami Hiramatsu
s_execve => do_syscall_64 => entry_SYSCALL_64_after_hwframe This shows int3 is nested. Signed-off-by: Masami Hiramatsu --- arch/x86/include/asm/kprobes.h |5 ++ arch/x86/kernel/kprobes/common.h | 39 +++ arch/x86/kernel/kprobes/core.c | 96 --

Re: [RFC PATCH bpf-next 0/3] bpf: add tracing for XDP programs using the BPF_PROG_TEST_RUN API

2020-05-07 Thread Masami Hiramatsu
On Tue, 5 May 2020 18:25:38 -0700 Alexei Starovoitov wrote: > On Thu, Apr 30, 2020 at 7:44 PM Masami Hiramatsu wrote: > > > > On Tue, 28 Apr 2020 09:19:47 -0300 > > Arnaldo Carvalho de Melo wrote: > > > > > Em Tue, Apr 28, 2020 at 12:47:53PM +0200, Eelco

Re: [RFC PATCH bpf-next 0/3] bpf: add tracing for XDP programs using the BPF_PROG_TEST_RUN API

2020-04-30 Thread Masami Hiramatsu
jited to. Are there any such information? Also, I would like to know the target BPF (XDP) is running in kprobes context or not. BPF tracer sometimes use the kprobes to hook the event and run in the kprobe (INT3) context. That will be need more work to probe it. For the BPF code which just runs in tracepoint context, it will be easy to probe it. (we may need to break a limitation of notrace, which we already has a kconfig) Thank you, -- Masami Hiramatsu

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-02 Thread Masami Hiramatsu
e several different confidentiality for each interface. Anyway, adding a tracefs mount option for allowing a user group to access event format data will be a good idea. But even though, I think we still need the CAP_TRACING for allowing control of intrusive tracing, like kprobes and bpf etc. (Or, do we keep those for CAP_SYS_ADMIN??) BTW, should we request CAP_SYS_PTRACE for ftrace uprobe interface too? It might break any user-space program (including init) if user puts a probe on a wrong address (e.g. non instruction boundary on x86). Thank you, -- Masami Hiramatsu

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Masami Hiramatsu
e you > allow tracing of the kernel, hiding /proc/kallsyms is pretty useless. Also, there is a blacklist of kprobes under debugfs. If CAP_TRACING introduced and it allows to access kallsyms, I would like to move the blacklist under tracefs, or make an alias of blacklist entry on tracefs. Thank you, -- Masami Hiramatsu

Re: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault

2019-02-28 Thread Masami Hiramatsu
between user/kernel addresses. In that > case reading the user pointer using user accessors (possibly using > bpf_probe_user_read helper) should be needed to fix this issue (as Yonghong > also privately discussed with me). OK, it sounds like the same issue. Please add a bpf_user_read() and use it for __user pointer. Thank you, -- Masami Hiramatsu

Re: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault

2019-02-25 Thread Masami Hiramatsu
he patching mm? > > > >>> > > > >>> Yes, this is a good point. I guess text_poke() should be defined with > > > >>> “__kprobes” and open-code memcpy. > > > >>> > > > >>> Does it sound reasonable? > > > >> > > > >> Doesn't __text_poke() as implemented in the proposed patch use a > > > >> couple other kernel functions, too? Like switch_mm_irqs_off() and > > > >> pte_clear() (which can be a call into a separate function on paravirt > > > >> kernels)? > > > > > > > > I will move the pte_clear() to be done after the poking mm was unloaded. > > > > Give me a few minutes to send a sketch of what I think should be done. > > > > > > Err.. You are right, I don’t see an easy way of preventing a kprobe from > > > being set on switch_mm_irqs_off(), and open-coding this monster is too > > > ugly. > > > > > > The reasonable solution seems to me as taking all the relevant pieces of > > > code (and data) that might be used during text-poking and encapsulating > > > them, so they > > > will be set in a memory area which cannot be kprobe'd. This can also be > > > useful to write-protect data structures of code that calls text_poke(), > > > e.g., static-keys. It can also protect data on that stack that is used > > > during text_poke() from being overwritten from another core. > > > > > > This solution is somewhat similar to Igor Stoppa’s idea of using > > > “enclaves” > > > when doing write-rarely operations. > > > > > > Right now, I think that text_poke() will keep being susceptible to such > > > an attack, unless you have a better suggestion. > > > > A relatively simple approach might be to teach BPF not to run kprobe > > programs and such in contexts where current->mm isn't the active mm? > > Maybe using nmi_uaccess_okay(), or something like that? It looks like > > perf_callchain_user() also already uses that. Except that a lot of > > this code is x86-specific... > > This sounds like exactly the right solution. If you're running from > some unknown context (like NMI or tracing), then you should check > nmi_uaccess_okay(). I think we should just promote that to be a > non-arch-specific function (that returns true by default) and check it > the relevant bpf_probe_xyz() functions. This treat may also need for my work, like probe_user_read() we should fail if nmi_uaccess_okay(). Thank you, > > Alexei, does that seem reasonable? -- Masami Hiramatsu

Re: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault

2019-02-22 Thread Masami Hiramatsu
values from kernel memory and that's no good, > but at least we won't be breaking them today, so we have time to > introduce bpf_user_read and bpf_kernel_read and folks have time to adopt them. I see. I think bpf also has to introduce new bpf_probe_read_user() and keep bpf_probe_read() for kernel dataa only. > Imo that's much better than making current bpf_probe_read() fail > on user addresses today and not providing a non disruptive path forward. Agreed. Thank you, -- Masami Hiramatsu

Re: [PATCH 0/2] Don’t leave executable TLB entries to freed pages

2018-11-29 Thread Masami Hiramatsu
On Thu, 29 Nov 2018 18:49:26 + "Edgecombe, Rick P" wrote: > On Thu, 2018-11-29 at 23:06 +0900, Masami Hiramatsu wrote: > > On Tue, 27 Nov 2018 16:07:52 -0800 > > Rick Edgecombe wrote: > > > > > Sometimes when memory is freed via the module subsyst

Re: [PATCH 0/2] Don’t leave executable TLB entries to freed pages

2018-11-29 Thread Masami Hiramatsu
ms good I can plug the flag in for other architectures > that > define PAGE_KERNEL_EXEC. > > > Rick Edgecombe (2): > vmalloc: New flag for flush before releasing pages > x86/modules: Make x86 allocs to flush when free > > arch/x86/kernel/module.c | 4 ++-- > i

Re: [PATCH v3 1/2] kretprobe: produce sane stack traces

2018-11-03 Thread Masami Hiramatsu
On Sat, 3 Nov 2018 13:30:21 -0400 Steven Rostedt wrote: > On Sun, 4 Nov 2018 01:34:30 +0900 > Masami Hiramatsu wrote: > > > > > I was thinking of a bitmask that represents the handlers, and use that > > > to map which handler gets called for which shadow ent

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 net-next] trace_events_filter: conditional trace event (tcp_probe full=0)

2018-02-12 Thread Masami Hiramatsu
) > fn = pred_funcs_s8[op - PRED_FUNC_START]; > else > @@ -1088,7 +1118,7 @@ static int init_pred(struct filter_parse_state *ps, > } > } > > - if (pred->op == OP_NE) > +if (pred->op == OP_NE || pred->op == OP_NE_PREV) > pred->not ^= 1; > > pred->fn = fn; > @@ -2197,7 +2227,7 @@ static int ftrace_function_check_pred(struct > filter_pred *pred, int leaf) > * - only '==' and '!=' is used > * - the 'ip' field is used > */ > -if ((pred->op != OP_EQ) && (pred->op != OP_NE)) > +if ((pred->op != OP_EQ) && (pred->op != OP_NE) && (pred->op > != OP_NE_PREV)) > return -EINVAL; > > if (strcmp(field->name, "ip")) > > > I'm new to upstream kernel development. Please let me any suggestion. > > Many thanks > Tamim > PhD Candidate, > Kent State University -- Masami Hiramatsu

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

[PATCH net-next v7 6/6] net: dccp: Remove dccpprobe module

2017-12-28 Thread Masami Hiramatsu
Remove DCCP probe module since jprobe has been deprecated. That function is now replaced by dccp/dccp_probe trace-event. You can use it via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- Changes in v5: - Fix a conflict with previous change in Makefile. --- net/dccp/Kconfig | 17

[PATCH net-next v7 4/6] net: sctp: Remove debug SCTP probe module

2017-12-28 Thread Masami Hiramatsu
Remove SCTP probe module since jprobe has been deprecated. That function is now replaced by sctp/sctp_probe and sctp/sctp_probe_path trace-events. You can use it via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- net/sctp/Kconfig | 12 --- net/sctp/Makefile |3 - net/sctp

[PATCH net-next v7 5/6] net: dccp: Add DCCP sendmsg trace event

2017-12-28 Thread Masami Hiramatsu
Add DCCP sendmsg trace event (dccp/dccp_probe) for replacing dccpprobe. User can trace this event via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- Changes in v5: - Fix to add local directory to include for trace.h. Thanks Steven! Changes in v7: - Avoid preprocessor

[PATCH net-next v7 3/6] net: sctp: Add SCTP ACK tracking trace event

2017-12-28 Thread Masami Hiramatsu
event is always invoked from sctp_probe event, you can not see any output if you only enable sctp_probe_path. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Add checking whether sctp_probe_path event is enabled before iterating sctp paths to record. Thanks Steven. Changes in v4:

[PATCH net-next v7 2/6] net: tcp: Remove TCP probe module

2017-12-28 Thread Masami Hiramatsu
Remove TCP probe module since jprobe has been deprecated. That function is now replaced by tcp/tcp_probe trace-event. You can use it via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- net/Kconfig | 17 --- net/ipv4/Makefile|1 net/ipv4/tcp_probe.c | 301

[PATCH net-next v7 1/6] net: tcp: Add trace events for TCP congestion window tracing

2017-12-28 Thread Masami Hiramatsu
1 > events/tcp/tcp_probe/enable (run workloads) # cat trace Signed-off-by: Masami Hiramatsu --- Changes in v6: - Avoid preprocessor directives in tracepoint macro args as Mat did on net tree. --- include/trace/events/tcp.h | 97 net/i

[PATCH net-next v7 0/6] net: tcp: sctp: dccp: Replace jprobe usage with trace events

2017-12-28 Thread Masami Hiramatsu
. Previous version is here; https://lkml.org/lkml/2017/12/28/7 Changes from v6: [5/6]: Avoid preprocessor directives in tracepoint macro args Thank you, --- Masami Hiramatsu (6): net: tcp: Add trace events for TCP congestion window tracing net: tcp: Remove TCP probe module net

Re: [PATCH net-next v6 0/6] net: tcp: sctp: dccp: Replace jprobe usage with trace events

2017-12-28 Thread Masami Hiramatsu
On Thu, 28 Dec 2017 12:06:13 -0500 (EST) David Miller wrote: > From: Masami Hiramatsu > Date: Thu, 28 Dec 2017 15:10:00 +0900 > > > Changes from v5: > > [1/6]: Avoid preprocessor directives in tracepoint macro args > > Patch #1 is not the only patch which has

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 situation was tested. > Instead I see only logical reasoning that it's _supposed_ to work. > That's not enough. OK, so would you just ask me to run samples/bpf ? Thanks, -- Masami Hiramatsu

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

[PATCH net-next v6 6/6] net: dccp: Remove dccpprobe module

2017-12-27 Thread Masami Hiramatsu
Remove DCCP probe module since jprobe has been deprecated. That function is now replaced by dccp/dccp_probe trace-event. You can use it via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- Changes in v5: - Fix a conflict with previous change in Makefile. --- net/dccp/Kconfig | 17

[PATCH net-next v6 1/6] net: tcp: Add trace events for TCP congestion window tracing

2017-12-27 Thread Masami Hiramatsu
1 > events/tcp/tcp_probe/enable (run workloads) # cat trace Signed-off-by: Masami Hiramatsu --- Changes in v6: - Avoid preprocessor directives in tracepoint macro args as Mat did on net tree. --- include/trace/events/tcp.h | 97 net/i

[PATCH net-next v6 2/6] net: tcp: Remove TCP probe module

2017-12-27 Thread Masami Hiramatsu
Remove TCP probe module since jprobe has been deprecated. That function is now replaced by tcp/tcp_probe trace-event. You can use it via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- net/Kconfig | 17 --- net/ipv4/Makefile|1 net/ipv4/tcp_probe.c | 301

[PATCH net-next v6 3/6] net: sctp: Add SCTP ACK tracking trace event

2017-12-27 Thread Masami Hiramatsu
event is always invoked from sctp_probe event, you can not see any output if you only enable sctp_probe_path. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Add checking whether sctp_probe_path event is enabled before iterating sctp paths to record. Thanks Steven. Changes in v4:

[PATCH net-next v6 4/6] net: sctp: Remove debug SCTP probe module

2017-12-27 Thread Masami Hiramatsu
Remove SCTP probe module since jprobe has been deprecated. That function is now replaced by sctp/sctp_probe and sctp/sctp_probe_path trace-events. You can use it via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- net/sctp/Kconfig | 12 --- net/sctp/Makefile |3 - net/sctp

[PATCH net-next v6 5/6] net: dccp: Add DCCP sendmsg trace event

2017-12-27 Thread Masami Hiramatsu
Add DCCP sendmsg trace event (dccp/dccp_probe) for replacing dccpprobe. User can trace this event via ftrace or perftools. Signed-off-by: Masami Hiramatsu --- Changes in v5 - Fix to add local directory to include for trace.h. Thanks Steven! --- net/dccp/Makefile |3 ++ net/dccp

[PATCH net-next v6 0/6] net: tcp: sctp: dccp: Replace jprobe usage with trace events

2017-12-27 Thread Masami Hiramatsu
Avoid preprocessor directives in tracepoint macro args Thank you, --- Masami Hiramatsu (6): net: tcp: Add trace events for TCP congestion window tracing net: tcp: Remove TCP probe module net: sctp: Add SCTP ACK tracking trace event net: sctp: Remove debug SCTP probe module net:

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, > >

Re: [PATCH net-next v5 1/6] net: tcp: Add trace events for TCP congestion window tracing

2017-12-26 Thread Masami Hiramatsu
On Tue, 26 Dec 2017 18:51:55 -0500 (EST) David Miller wrote: > From: Masami Hiramatsu > Date: Fri, 22 Dec 2017 11:05:33 +0900 > > > This adds an event to trace TCP stat variables with > > slightly intrusive trace-event. This uses ftrace/perf > > event log buffer to

[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:

  1   2   >