Re: linux-next: build failure after merge of the net-next tree

2018-01-10 Thread Alexei Starovoitov
On Thu, Jan 11, 2018 at 11:53:55AM +1100, Stephen Rothwell wrote: > Hi all, > > After merging the net-next tree, today's linux-next build (x86_64 > allmodconfig) failed like this: > > kernel/bpf/verifier.o: In function `bpf_check': > verifier.c:(.text+0xd86e): undefined reference to `bpf_patch_ca

Re: [PATCH][bpf-next] bpf: fix spelling mistake: "obusing" -> "abusing"

2018-01-10 Thread Alexei Starovoitov
On Wed, Jan 10, 2018 at 11:39:14AM +0100, Daniel Borkmann wrote: > On 01/10/2018 10:20 AM, Colin King wrote: > > From: Colin Ian King > > > > Trivial fix to spelling mistake in error message text. > > > > Signed-off-by: Colin Ian King > > --- > > kernel/bpf/verifier.c | 2 +- > > 1 file change

Re: [PATCH 16/18] net: mpls: prevent bounds-check bypass via speculative execution

2018-01-09 Thread Alexei Starovoitov
On Tue, Jan 09, 2018 at 06:22:09PM -0800, Dan Williams wrote: > > When you came up with that tweak you noted: > > "The following: > [..] > is generic and no speculative flows." I meant 'no speculative control flow' load speculation still happens. > > > This macro doesn't prevent speculation. >

Re: [PATCH 16/18] net: mpls: prevent bounds-check bypass via speculative execution

2018-01-09 Thread Alexei Starovoitov
On Tue, Jan 09, 2018 at 04:48:24PM -0800, Dan Williams wrote: > > #define __nospec_array_ptr(base, idx, sz) \ > ({ \ > union { typeof(&base[0]) _ptr; unsigned long _bit; } __u; \ >

[PATCH v3 bpf] bpf: introduce BPF_JIT_ALWAYS_ON config

2018-01-09 Thread Alexei Starovoitov
l variable from all JITs, consolidate in one place and remove this jit_init() function. Signed-off-by: Alexei Starovoitov --- init/Kconfig | 7 +++ kernel/bpf/core.c | 19 +++ lib/test_bpf.c | 11 +++ net/core/filter.c |

[PATCH v2 bpf] bpf: introduce BPF_JIT_ALWAYS_ON config

2018-01-08 Thread Alexei Starovoitov
ne extra hunk. It will be sent when the trees are merged back to net-next Considered doing: int bpf_jit_enable __read_mostly = BPF_EBPF_JIT_DEFAULT; but it seems better to land the patch as-is and in bpf-next remove bpf_jit_enable global variable from all JITs, consolidate in one place and remo

Re: linux-next: manual merge of the net-next tree with the bpf tree

2018-01-08 Thread Alexei Starovoitov
On Tue, Jan 09, 2018 at 11:21:25AM +1100, Stephen Rothwell wrote: > Hi all, > > Today's linux-next merge of the net-next tree got a conflict in: > > tools/testing/selftests/bpf/test_align.c > > between commit: > > 2b36047e7889 ("selftests/bpf: fix test_align") > > from the bpf tree and com

Re: [PATCH v6 00/10] Retpoline: Avoid speculative indirect calls in kernel

2018-01-08 Thread Alexei Starovoitov
On Mon, Jan 08, 2018 at 02:42:13AM -0800, Paul Turner wrote: > > kernel->kernel independent of SMEP: > While much harder to coordinate, facilities such as eBPF potentially > allow exploitable return targets to be created. > Generally speaking (particularly if eBPF has been disabled) the risk > is

Re: general protection fault in free_verifier_state (2)

2018-01-08 Thread Alexei Starovoitov
On Mon, Jan 8, 2018 at 2:58 AM, syzbot wrote: > Hello, > > syzkaller hit the following crash on > 895c0dde398510a5b5ded60e5064c11b94bd30ca > git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master > compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console output is a

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

2018-01-07 Thread Alexei Starovoitov
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, please resend your patches. I think 2 and 3 were nice simplifications. and patch 1 is good too if it's passes the

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-07 Thread Alexei Starovoitov
On Sun, Jan 07, 2018 at 01:59:35PM +, Alan Cox wrote: > > which means that POC is relying 64-bit address speculation. > > In the places coverity found the user supplied value is 32-bit, > > People have 32bit computers as well as 64bit and in some cases 32bit is > fine for an attack depending w

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-07 Thread Alexei Starovoitov
On Sun, Jan 07, 2018 at 12:15:40PM -0800, Dan Williams wrote: > > I'm thinking we should provide the option to at least build the > hot-path nospec_array_ptr() usages without an lfence. > > CONFIG_SPECTRE1_PARANOIA_SAFE > CONFIG_SPECTRE1_PARANOIA_PERF SAFE vs PERF naming is problematic a

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-07 Thread Alexei Starovoitov
On Sun, Jan 07, 2018 at 11:08:24AM +0100, Thomas Gleixner wrote: > On Sat, 6 Jan 2018, Alexei Starovoitov wrote: > > which clearly states that bpf_tail_call() was used in the attack. > > Yet none of the intel nor arm patches address speculation in > > this bpf helper! > &g

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-06 Thread Alexei Starovoitov
On Sat, Jan 06, 2018 at 11:05:07PM +, Alan Cox wrote: > > Even if it would be practical the speed probably going to be in bytes per > > second, > > so to read anything meaningful an attack detection techniques (that people > > are actively working on) will be able to catch it. > > At the end s

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-06 Thread Alexei Starovoitov
On Sat, Jan 06, 2018 at 08:22:13PM +, Alan Cox wrote: > > "Value prediction consists of predicting entire 32- and 64-bit register > > values > > based on previously-seen values" > > For their implementation yes > > > > > > In other words there are at least two problems with Linus proposal

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-06 Thread Alexei Starovoitov
On Sat, Jan 06, 2018 at 07:55:51PM +, Alan Cox wrote: > > cpus execute what they see. speculative execution does the same > > except results are not committed to visible registers and stay > > in renanmed/shadow set. There is no 'undo' of the speculative execution. > > The whole issue is that c

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-06 Thread Alexei Starovoitov
On Sat, Jan 06, 2018 at 10:54:27AM -0800, Dan Williams wrote: > On Sat, Jan 6, 2018 at 10:39 AM, Alexei Starovoitov > wrote: > [..] > >> retpoline is variant-2, this patch series is about variant-1. > > > > that's exactly the point. Don't slow down the ke

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-06 Thread Alexei Starovoitov
On Sat, Jan 06, 2018 at 06:38:59PM +, Alan Cox wrote: > On Sat, 6 Jan 2018 10:13:33 -0800 > Alexei Starovoitov wrote: > > > On Sat, Jan 06, 2018 at 12:32:42PM +, Alan Cox wrote: > > > On Fri, 5 Jan 2018 18:52:07 -0800 > > > Linus Torvalds wrote: > >

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-06 Thread Alexei Starovoitov
On Sat, Jan 06, 2018 at 10:29:49AM -0800, Dan Williams wrote: > On Sat, Jan 6, 2018 at 10:13 AM, Alexei Starovoitov > wrote: > > On Sat, Jan 06, 2018 at 12:32:42PM +, Alan Cox wrote: > >> On Fri, 5 Jan 2018 18:52:07 -0800 > >> Linus Torvalds wrote: > >>

Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

2018-01-06 Thread Alexei Starovoitov
On Sat, Jan 06, 2018 at 12:32:42PM +, Alan Cox wrote: > On Fri, 5 Jan 2018 18:52:07 -0800 > Linus Torvalds wrote: > > > On Fri, Jan 5, 2018 at 5:10 PM, Dan Williams > > wrote: > > > From: Andi Kleen > > > > > > When access_ok fails we should always stop speculating. > > > Add the required

Re: [RFCv2 4/4] bpf: inhibit speculated out-of-bounds pointers

2018-01-05 Thread Alexei Starovoitov
On Fri, Jan 05, 2018 at 02:57:50PM +, Mark Rutland wrote: > Note: this patch is an *example* use of the nospec API. It is understood > that this is incomplete, etc. > > Under speculation, CPUs may mis-predict branches in bounds checks. Thus, > memory accesses under a bounds check may be specul

Re: [PATCH v3 01/13] x86/retpoline: Add initial retpoline support

2018-01-04 Thread Alexei Starovoitov
On Thu, Jan 04, 2018 at 10:25:35AM -0800, Linus Torvalds wrote: > On Thu, Jan 4, 2018 at 10:17 AM, Alexei Starovoitov > wrote: > > > > Clearly Paul's approach to retpoline without lfence is faster. > > I'm guessing it wasn't shared with amazon/intel until n

Re: [PATCH v3 01/13] x86/retpoline: Add initial retpoline support

2018-01-04 Thread Alexei Starovoitov
On Thu, Jan 04, 2018 at 02:36:58PM +, David Woodhouse wrote: > Enable the use of -mindirect-branch=thunk-extern in newer GCC, and provide > the corresponding thunks. Provide assembler macros for invoking the thunks > in the same way that GCC does, from native and inline assembler. > > This add

Re: [RFC PATCH] asm/generic: introduce if_nospec and nospec_barrier

2018-01-03 Thread Alexei Starovoitov
On Thu, Jan 04, 2018 at 02:15:53AM +, Alan Cox wrote: > > > > Elena has done the work of auditing static analysis reports to a dozen > > > or so locations that need some 'nospec' handling. > > > > How exactly is that related (especially in longer-term support terms) to > > BPF anyway? > >

Re: WARNING in adjust_ptr_min_max_vals

2018-01-02 Thread Alexei Starovoitov
On Tue, Jan 02, 2018 at 08:58:01PM -0800, syzbot wrote: > Hello, > > syzkaller hit the following crash on > 0e08c463db387a2adcb0243b15ab868a73f87807 > git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master > compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console o

Re: general protection fault in copy_verifier_state

2018-01-02 Thread Alexei Starovoitov
On Tue, Jan 02, 2018 at 02:58:01PM -0800, syzbot wrote: > Hello, > > syzkaller hit the following crash on > 6bb8824732f69de0f233ae6b1a8158e149627b38 > git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master > compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console ou

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

2017-12-28 Thread Alexei Starovoitov
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, for example, obj = func_return_object(); if (!obj) { handling_error...; } obj->field = x; In this case,

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

2017-12-28 Thread Alexei Starovoitov
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 2017 19:45:42 -0800 Alexei Starovoitov wrote: I don't think that's the case. My reading of current trace_kpr

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

2017-12-27 Thread Alexei Starovoitov
On 12/27/17 8:16 PM, Steven Rostedt wrote: On Wed, 27 Dec 2017 19:45:42 -0800 Alexei Starovoitov wrote: I don't think that's the case. My reading of current trace_kprobe_ftrace() -> arch_check_ftrace_location() is that it will not be true for old mcount case. In the old mco

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

2017-12-27 Thread Alexei Starovoitov
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 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

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

2017-12-27 Thread Alexei Starovoitov
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 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

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

2017-12-27 Thread Alexei Starovoitov
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: Support in-kernel fault-injection framework via debugfs. This allows you to inject a conditional error to specified

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

2017-12-27 Thread Alexei Starovoitov
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: Check whether error injectable event is on function entry or not. Currently it checks the event is ftrace-based kprobes

Re: [PATCH 4/4] libbpf: add missing SPDX-License-Identifier

2017-12-27 Thread Alexei Starovoitov
On Wed, Dec 27, 2017 at 07:02:29PM +0100, Eric Leblond wrote: > Signed-off-by: Eric Leblond thank you. Acked-by: Alexei Starovoitov

Re: [PATCH 3/4] libbpf: break loop earlier

2017-12-27 Thread Alexei Starovoitov
On Wed, Dec 27, 2017 at 07:02:28PM +0100, Eric Leblond wrote: > Get out of the loop when we have a match. > > Signed-off-by: Eric Leblond > --- > tools/lib/bpf/libbpf.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 5fe8aaa2123e.

Re: [PATCH 1/4] libbpf: add function to setup XDP

2017-12-27 Thread Alexei Starovoitov
On Wed, Dec 27, 2017 at 07:02:26PM +0100, Eric Leblond wrote: > Most of the code is taken from set_link_xdp_fd() in bpf_load.c and > slightly modified to be library compliant. > > Signed-off-by: Eric Leblond Acked-by: Alexei Starovoitov

Re: [PATCH 2/4] libbpf: add error reporting in XDP

2017-12-27 Thread Alexei Starovoitov
On Wed, Dec 27, 2017 at 07:02:27PM +0100, Eric Leblond wrote: > Parse netlink ext attribute to get the error message returned by > the card. Code is partially take from libnl. > > Signed-off-by: Eric Leblond Acked-by: Alexei Starovoitov

Re: [lkp-robot] [bpf] 82abbf8d2f: kernel_selftests.bpf.test_align.fail

2017-12-26 Thread Alexei Starovoitov
On Wed, Dec 27, 2017 at 11:00:30AM +0800, kernel test robot wrote: > > FYI, we noticed the following commit (built with gcc-7): > > commit: 82abbf8d2fc46d79611ab58daa7c608df14bb3ee ("bpf: do not allow root to > mangle valid pointers") > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux

Re: [PATCH v2 bpf-next 2/2] tools/bpftool: fix bpftool build with bintutils >= 2.8

2017-12-26 Thread Alexei Starovoitov
t; > Fix this by adding a new "feature" to the tools/build/features > > infrastructure and make it responsible for decision which > > disassembler() function signature to use. > > > > Signed-off-by: Roman Gushchin > > Cc: Jakub Kicinski > >

Re: [PATCH bpf-next 2/3] libbpf: add error reporting in XDP

2017-12-26 Thread Alexei Starovoitov
On Mon, Dec 25, 2017 at 11:13:24PM +0100, Eric Leblond wrote: > Parse netlink ext attribute to get the error message returned by > the card. > > Signed-off-by: Eric Leblond ... > diff --git a/tools/lib/bpf/nlattr.c b/tools/lib/bpf/nlattr.c > new file mode 100644 > index ..962de14f74e3

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

2017-12-26 Thread Alexei Starovoitov
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 using debugfs interfaces. > > Signed-off-by: Masami Hiramatsu > --- > Documentation/fault-injection

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

2017-12-26 Thread Alexei Starovoitov
tion_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 entry. looks like nice cleanup. Acked-by: Alexei Starovoitov

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

2017-12-26 Thread Alexei Starovoitov
(bpf_kprobe_override)) { > - __this_cpu_write(bpf_kprobe_override, 0); > + if (orig_ip != instruction_pointer(regs)) { > reset_current_kprobe(); > + preempt_enable_no_resched(); This is great idea. Acked-by: Alexei Starovoitov

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

2017-12-26 Thread Alexei Starovoitov
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, > but that is wrong. It should check if the event is on the entry > of target function. Since error i

kasan for bpf

2017-12-22 Thread Alexei Starovoitov
Hi All, the recent bugs make people question the safety of bpf and not a surprise that some folks propose to set kernel.unprivileged_bpf_disabled = 1 by default. I think it will be wrong long term decision, since it will steer bpf into "root only" mentality. The verifier checks will become sloppi

Re: [PATCH] bpf: selftest for late caller stack size increase

2017-12-22 Thread Alexei Starovoitov
On Fri, Dec 22, 2017 at 07:12:35PM +0100, Jann Horn wrote: > This checks that it is not possible to bypass the total stack size check in > update_stack_depth() by calling a function that uses a large amount of > stack memory *before* using a large amount of stack memory in the caller. > > Currentl

Re: correctness of BPF stack size checking logic for multi-function programs?

2017-12-21 Thread Alexei Starovoitov
On Fri, Dec 22, 2017 at 02:14:45AM +0100, Jann Horn wrote: > Hi! > > I saw the recently-added support for multiple functions in a single > program in BPF. I've stumbled over something that looks like it might > be a bug; I haven't verified it yet, but I thought I should give you a > heads-up befor

tracepoint_probe_register and bpf. Was: [PATCH tip 0/3] Improvements of scheduler related Tracepoints

2017-12-20 Thread Alexei Starovoitov
On Mon, Dec 18, 2017 at 10:11:57AM +0100, Peter Zijlstra wrote: > On Fri, Dec 15, 2017 at 09:09:51AM -0800, Alexei Starovoitov wrote: > > > yeah. Currently bpf progs are called at the end of > > perf_trace_##call() > > { > > .. regular tracepoint copy craft &

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

2017-12-20 Thread Alexei Starovoitov
On 12/20/17 3:00 AM, Masami Hiramatsu wrote: On Fri, 15 Dec 2017 14:12:52 -0500 Josef Bacik wrote: From: Josef Bacik Using BPF we can override kprob'ed functions and return arbitrary values. Obviously this can be a bit unsafe, so make this feature opt-in for functions. Simply tag a functio

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

2017-12-20 Thread Alexei Starovoitov
On 12/19/17 11:13 PM, Masami Hiramatsu wrote: 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_KPROBE_OVERRIDE is also co

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

2017-12-19 Thread Alexei Starovoitov
On 12/18/17 10:29 PM, Masami Hiramatsu wrote: +#if defined(__KERNEL__) && !defined(__ASSEMBLY__) +#ifdef CONFIG_BPF_KPROBE_OVERRIDE BTW, CONFIG_BPF_KPROBE_OVERRIDE is also confusable name. Since this feature override a function to just return with some return value (as far as I understand, or

Re: [PATCH] bpf: fix BPF_KPROBE_OVERRIDE dependencies

2017-12-19 Thread Alexei Starovoitov
On Tue, Dec 19, 2017 at 11:12:04AM +0100, Arnd Bergmann wrote: > CONFIG_BPF_KPROBE_OVERRIDE causes a link failure when CONFIG_KPROBE_EVENTS > is disabled: > > kernel/trace/bpf_trace.o: In function `bpf_override_return': > (.text+0x172): undefined reference to `bpf_kprobe_override' > > This adds i

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

2017-12-19 Thread Alexei Starovoitov
On Tue, Dec 19, 2017 at 05:56:55PM +0900, Masami Hiramatsu wrote: > include/trace/events/sctp.h | 98 ++ > include/trace/events/tcp.h | 80 +++ > net/Kconfig | 17 -- > net/dccp/Kconfig| 17 -- > net/dccp/Makefile |2 > net/dc

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

2017-12-15 Thread Alexei Starovoitov
On 12/15/17 11:12 AM, Josef Bacik wrote: +#ifdef CONFIG_BPF_KPROBE_OVERRIDE +BPF_CALL_2(bpf_override_return, struct pt_regs *, regs, unsigned long, rc) +{ + __this_cpu_write(bpf_kprobe_override, 1); + regs_set_return_value(regs, rc); + arch_ftrace_kprobe_override_function(regs);

Re: [PATCH tip 0/3] Improvements of scheduler related Tracepoints

2017-12-15 Thread Alexei Starovoitov
On 12/14/17 11:39 PM, Peter Zijlstra wrote: On Thu, Dec 14, 2017 at 07:16:00PM -0800, Alexei Starovoitov wrote: On 12/14/17 12:49 PM, Peter Zijlstra wrote: On Thu, Dec 14, 2017 at 12:20:41PM -0800, Teng Qin wrote: This set of commits attempts to improve three scheduler related Tracepoints

Re: [PATCH tip 0/3] Improvements of scheduler related Tracepoints

2017-12-14 Thread Alexei Starovoitov
On 12/14/17 12:49 PM, Peter Zijlstra wrote: On Thu, Dec 14, 2017 at 12:20:41PM -0800, Teng Qin wrote: This set of commits attempts to improve three scheduler related Tracepoints: sched_switch, sched_process_fork, sched_process_exit. Firstly, these commit add additional flag values, namely preem

Re: linux-next: build failure after merge of the bpf-next tree

2017-12-12 Thread Alexei Starovoitov
On Wed, Dec 13, 2017 at 12:32:45PM +1100, Stephen Rothwell wrote: > Hi all, > > After merging the bpf-next tree, today's linux-next build (arm > multi_v7_defconfig) failed like this: > > kernel/events/core.o: In function `perf_ioctl': > core.c:(.text+0x98c4): undefined reference to `bpf_event_que

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

2017-12-12 Thread Alexei Starovoitov
On 12/11/17 8:36 AM, Josef Bacik wrote: This is the same as v8, just rebased onto the bpf tree. v8->v9: - rebased onto the bpf tree. v7->v8: - removed the _ASM_KPROBE_ERROR_INJECT since it was not needed. v6->v7: - moved the opt-in macro to bpf.h out of kprobes.h. v5->v6: - add BPF_ALLOW_ERRO

Re: [PATCH net-next] libbpf: add function to setup XDP

2017-12-09 Thread Alexei Starovoitov
On Sat, Dec 09, 2017 at 09:34:46AM -0700, David Ahern wrote: > On 12/9/17 7:43 AM, Eric Leblond wrote: > > + /* started nested attribute for XDP */ > > + nla = (struct nlattr *)(((char *)&req) > > + + NLMSG_ALIGN(req.nh.nlmsg_len)); > > + nla->nla_type = NLA_F_NESTED

Re: [PATCH v3 1/6] perf: prepare perf_event.h for new types perf_kprobe and perf_uprobe

2017-12-04 Thread Alexei Starovoitov
On 12/4/17 10:24 AM, Song Liu wrote: On Dec 3, 2017, at 9:03 AM, Alexei Starovoitov wrote: On Thu, Nov 30, 2017 at 03:50:18PM -0800, Song Liu wrote: Two new perf types, perf_kprobe and perf_uprobe, will be added to allow creating [k,u]probe with perf_event_open. These [k,u]probe are

Re: [PATCH 1/5] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-03 Thread Alexei Starovoitov
Brueckner > Reviewed-and-tested-by: Thomas Richter > Cc: Arnaldo Carvalho de Melo > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Alexander Shishkin > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Arnd Bergmann > Cc: Alexei Starovoitov > Cc: Daniel B

Re: [PATCH v3 1/6] perf: prepare perf_event.h for new types perf_kprobe and perf_uprobe

2017-12-03 Thread Alexei Starovoitov
is NULL), or [k,u]probe offset. > > Signed-off-by: Song Liu > Reviewed-by: Yonghong Song > Reviewed-by: Josef Bacik > Acked-by: Alexei Starovoitov > --- > include/uapi/linux/perf_event.h | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/include/uapi/linux/pe

Re: [PATCH] compiler, clang: handle randomizable anonymous structs

2017-12-01 Thread Alexei Starovoitov
On Thu, Nov 09, 2017 at 12:16:45PM +0530, Sandipan Das wrote: > The GCC randomize layout plugin can randomize the member > offsets of sensitive kernel data structures. To use this > feature, certain annotations and members are added to the > structures which affect the member offsets even if this >

Re: [PATCH/RFC] Re: 'perf test BPF' failing, libbpf regression wrt "basic API for BPF obj name"

2017-12-01 Thread Alexei Starovoitov
On 12/1/17 9:51 AM, Arnaldo Carvalho de Melo wrote: But this is not just testcase expectations, the usecase is someone wanting to use a newer tool, with perhaps some new features of interest that don't depend on changes in the kernel, in an older kernel on a system where updating it is not possi

Re: [PATCH/RFC] Re: 'perf test BPF' failing, libbpf regression wrt "basic API for BPF obj name"

2017-11-30 Thread Alexei Starovoitov
On 11/30/17 11:00 AM, Arnaldo Carvalho de Melo wrote: Instead of sinking all future bpf_attr's backward compatibility requirements to sys_bpf, I would push it up to its own BPF_* command helper which has a better sense of its bpf_attr, i.e. push it up to bpf_create_map_node() and bpf_load_progra

Re: [PATCH 1/6] perf: Add new type PERF_TYPE_PROBE

2017-11-25 Thread Alexei Starovoitov
On 11/24/17 12:28 AM, Peter Zijlstra wrote: On Thu, Nov 23, 2017 at 10:31:29PM -0800, Alexei Starovoitov wrote: unfortunately 32-bit is more screwed than it seems: $ cat align.c #include struct S { unsigned long long a; } s; struct U { unsigned long long a; } u; int main

Re: [PATCH 1/6] perf: Add new type PERF_TYPE_PROBE

2017-11-23 Thread Alexei Starovoitov
On 11/23/17 2:02 AM, Peter Zijlstra wrote: On Wed, Nov 15, 2017 at 09:23:33AM -0800, Song Liu wrote: Note: We use type __u64 for pointer probe_desc instead of __aligned_u64. The reason here is to avoid changing the size of struct perf_event_attr, and breaking new-kernel-old-utility scenario. To

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

2017-11-22 Thread Alexei Starovoitov
On Wed, Nov 22, 2017 at 04:23:29PM -0500, Josef Bacik wrote: > This is hopefully the final version, I've addressed the comment by Igno and > added his Acks. > > v6->v7: > - moved the opt-in macro to bpf.h out of kprobes.h. Thanks Josef! All patches look great to me. We'll probably take them all i

Re: [PATCH 0/6] enable creating [k,u]probe with perf_event_open

2017-11-21 Thread Alexei Starovoitov
On Wed, Nov 15, 2017 at 09:23:31AM -0800, Song Liu wrote: > Changes RFC v2 to PATCH v1: > Check type PERF_TYPE_PROBE in perf_event_set_filter(). > Rebase on to tip perf/core. > > Changes RFC v1 to RFC v2: > Fix build issue reported by kbuild test bot by adding ifdef of > CONFIG_KPROBE_EVEN

Re: [ftrace-bpf 1/5] add BPF_PROG_TYPE_FTRACE to bpf

2017-11-17 Thread Alexei Starovoitov
On Mon, Nov 13, 2017 at 12:06:17AM -0800, peng yu wrote: > > 1. anything bpf related has to go via net-next tree. > I found there is a net-next git repo: > https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git > I will use this repo for the further bpf-ftrace patch set. > > > 2. > > t

Re: [ftrace-bpf 1/5] add BPF_PROG_TYPE_FTRACE to bpf

2017-11-12 Thread Alexei Starovoitov
On Sun, Nov 12, 2017 at 07:28:24AM +, yupeng0...@gmail.com wrote: > Add a new type BPF_PROG_TYPE_FTRACE to bpf, let bpf can be attached to > ftrace. Ftrace pass the function parameters to bpf prog, bpf prog > return 1 or 0 to indicate whether ftrace can trace this function. The > major propose

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-11 Thread Alexei Starovoitov
On 11/11/17 4:14 PM, Ingo Molnar wrote: * Josef Bacik wrote: On Fri, Nov 10, 2017 at 10:34:59AM +0100, Ingo Molnar wrote: * Josef Bacik wrote: @@ -551,6 +578,10 @@ static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func return &bpf_get_stackid_pr

Re: [PATCH] net/tcp: introduce TRACE_EVENT for TCP/IPv4 state transition

2017-11-08 Thread Alexei Starovoitov
On Thu, Nov 09, 2017 at 02:01:38PM +0800, Yafang Shao wrote: > With this newly introduced TRACE_EVENT, it will be very easy to minotor > TCP/IPv4 state transition. > > A new TRACE_SYSTEM named tcp is added, in which we can trace other TCP > event as well. > > Two helpers are added, > static inlin

Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members

2017-11-07 Thread Alexei Starovoitov
On 11/8/17 6:47 AM, Y Song wrote: On Tue, Nov 7, 2017 at 1:39 PM, Alexei Starovoitov wrote: On 11/8/17 6:14 AM, Y Song wrote: On Tue, Nov 7, 2017 at 12:37 AM, Naveen N. Rao wrote: Alexei Starovoitov wrote: On 11/7/17 12:55 AM, Naveen N. Rao wrote: I thought such struct shouldn&#

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

2017-11-07 Thread Alexei Starovoitov
On 11/8/17 5:28 AM, Josef Bacik wrote: I'm sending this through Dave since it'll conflict with other BPF changes in his tree, but since it touches tracing as well Dave would like a review from somebody on the tracing side. v4->v5: - disallow kprobe_override programs from being put in the prog ma

Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members

2017-11-07 Thread Alexei Starovoitov
On 11/8/17 6:14 AM, Y Song wrote: On Tue, Nov 7, 2017 at 12:37 AM, Naveen N. Rao wrote: Alexei Starovoitov wrote: On 11/7/17 12:55 AM, Naveen N. Rao wrote: I thought such struct shouldn't change layout. If it is we need to fix include/linux/compiler-clang.h to do that anon struct as

Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members

2017-11-07 Thread Alexei Starovoitov
On 11/7/17 12:55 AM, Naveen N. Rao wrote: I thought such struct shouldn't change layout. If it is we need to fix include/linux/compiler-clang.h to do that anon struct as well. We considered that, but it looked to be very dependent on the version of gcc used to build the kernel. But, this may be

Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members

2017-11-04 Thread Alexei Starovoitov
On 11/5/17 2:31 AM, Naveen N. Rao wrote: Hi Alexei, Alexei Starovoitov wrote: On 11/3/17 3:58 PM, Sandipan Das wrote: For added security, the layout of some structures can be randomized by enabling CONFIG_GCC_PLUGIN_RANDSTRUCT. One such structure is task_struct. To build BPF programs, we use

Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members

2017-11-04 Thread Alexei Starovoitov
On 11/3/17 3:58 PM, Sandipan Das wrote: For added security, the layout of some structures can be randomized by enabling CONFIG_GCC_PLUGIN_RANDSTRUCT. One such structure is task_struct. To build BPF programs, we use Clang which does not support this feature. So, if we attempt to read a field of a

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-03 Thread Alexei Starovoitov
On Fri, Nov 03, 2017 at 05:52:22PM +0100, Daniel Borkmann wrote: > On 11/03/2017 03:31 PM, Josef Bacik wrote: > > On Fri, Nov 03, 2017 at 12:12:13AM +0100, Daniel Borkmann wrote: > > > Hi Josef, > > > > > > one more issue I just noticed, see comment below: > > > > > > On 11/02/2017 03:37 PM, Jose

Re: [PATCH 1/2] [net-next] bpf: fix link error without CONFIG_NET

2017-11-02 Thread Alexei Starovoitov
18aaf8a4 ("bpf: move knowledge about post-translation offsets > > out of verifier") > > Signed-off-by: Arnd Bergmann > > Thanks Arnd! I was hoping to nuke this code before build bots catch up > to me, didn't work out :) yeah. Jakub's patches may not make it in time for net-next closing. so let's use this fix for now. Acked-by: Alexei Starovoitov

Re: [PATCH 2/2] [net-next] bpf: fix out-of-bounds access warning in bpf_check

2017-11-02 Thread Alexei Starovoitov
On Thu, Nov 02, 2017 at 05:14:00PM +0100, Arnd Bergmann wrote: > On Thu, Nov 2, 2017 at 4:59 PM, Alexei Starovoitov > wrote: > > On Thu, Nov 02, 2017 at 12:05:52PM +0100, Arnd Bergmann wrote: > >> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > >> in

Re: [PATCH 2/2] [net-next] bpf: fix out-of-bounds access warning in bpf_check

2017-11-02 Thread Alexei Starovoitov
On Thu, Nov 02, 2017 at 12:05:52PM +0100, Arnd Bergmann wrote: > The bpf_verifer_ops array is generated dynamically and may be > empty depending on configuration, which then causes an out > of bounds access: > > kernel/bpf/verifier.c: In function 'bpf_check': > kernel/bpf/verifier.c:4320:29: error

Re: [PATCH v2 net-next 3/5] bpf, cgroup: implement eBPF-based device controller for cgroup v2

2017-11-02 Thread Alexei Starovoitov
On 11/2/17 7:54 AM, Roman Gushchin wrote: +#define DEV_BPF_ACC_MKNOD (1ULL << 0) +#define DEV_BPF_ACC_READ (1ULL << 1) +#define DEV_BPF_ACC_WRITE (1ULL << 2) + +#define DEV_BPF_DEV_BLOCK (1ULL << 0) +#define DEV_BPF_DEV_CHAR (1ULL << 1) + all macros in bpf.h start wit

Re: [PATCH net-next V2 3/3] tun: add eBPF based queue selection method

2017-11-01 Thread Alexei Starovoitov
On Wed, Nov 01, 2017 at 03:59:48PM +0200, Michael S. Tsirkin wrote: > On Wed, Nov 01, 2017 at 09:02:03PM +0800, Jason Wang wrote: > > > > > > On 2017年11月01日 00:45, Michael S. Tsirkin wrote: > > > > +static void __tun_set_steering_ebpf(struct tun_struct *tun, > > > > +

Re: [PATCH 2/2] samples/bpf: add a test for bpf_override_return

2017-11-01 Thread Alexei Starovoitov
Bacik Acked-by: Alexei Starovoitov +++ b/samples/bpf/test_override_return.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +rm -f testfile.img +dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1 +DEVICE=$(losetup --show -f testfile.img) +mkfs.btrfs -f $DEVICE +mkdir tmpmnt +./tracex7 $DEVICE +if [ $?

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-11-01 Thread Alexei Starovoitov
injection for all of our code paths. Signed-off-by: Josef Bacik Both bpf and tracing bits look great to me. Acked-by: Alexei Starovoitov

Re: linux-next: manual merge of the tip tree with the net-next tree

2017-11-01 Thread Alexei Starovoitov
On Wed, Nov 01, 2017 at 09:55:24AM +0100, Peter Zijlstra wrote: > On Wed, Nov 01, 2017 at 09:27:43AM +0100, Ingo Molnar wrote: > > > > * Peter Zijlstra wrote: > > > > > On Wed, Nov 01, 2017 at 06:15:54PM +1100, Stephen Rothwell wrote: > > > > Hi all, > > > > > > > > Today's linux-next merge of

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-10-31 Thread Alexei Starovoitov
On 10/31/17 8:45 AM, Josef Bacik wrote: From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Acco

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

2017-10-31 Thread Alexei Starovoitov
On 10/31/17 6:55 PM, David Miller wrote: From: Josef Bacik Date: Tue, 31 Oct 2017 11:45:55 -0400 v1->v2: - moved things around to make sure that bpf_override_return could really only be used for an ftrace kprobe. - killed the special return values from trace_call_bpf. - renamed pc_modified t

Re: [PATCH 2/2] samples/bpf: add a test for bpf_override_return

2017-10-30 Thread Alexei Starovoitov
On 10/30/17 2:19 PM, Josef Bacik wrote: + +rm -f testfile.img +dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1 +DEVICE=$(losetup --show -f testfile.img) +mkfs.btrfs -f $DEVICE +mkdir tmpmnt +./tracex7 $DEVICE +if [ $? -eq 0 ] +then + echo "SUCCESS!" +else + echo "FAILED!" +fi

Re: [PATCH 1/2] bpf: add a bpf_override_function helper

2017-10-30 Thread Alexei Starovoitov
On 10/30/17 2:19 PM, Josef Bacik wrote: From: Josef Bacik Error injection is sloppy and very ad-hoc. BPF could fill this niche perfectly with it's kprobe functionality. We could make sure errors are only triggered in specific call chains that we care about with very specific situations. Acco

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Alexei Starovoitov
On Tue, Oct 24, 2017 at 11:53:20AM +0800, Herbert Xu wrote: > On Mon, Oct 23, 2017 at 10:50:43PM -0500, Gustavo A. R. Silva wrote: > > > > Quoting Herbert Xu : > > > > >On Mon, Oct 23, 2017 at 01:18:57PM -0500, Gustavo A. R. Silva wrote: > > >>Use BUG_ON instead of if condition followed by BUG. >

Re: [PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-20 Thread Alexei Starovoitov
On Fri, Oct 20, 2017 at 11:57:48PM +0800, j...@suse.com wrote: > On Fri, Oct 20, 2017 at 09:08:48AM +0100, David Howells wrote: > > Hi Joey, > > > > Should I just lock down sys_bpf() entirely for now? We can always free it > > up > > somewhat later. > > > > David > > OK~~ Please just remove my

Re: [PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-19 Thread Alexei Starovoitov
On Thu, Oct 19, 2017 at 11:48:34PM +0100, David Howells wrote: > Alexei Starovoitov wrote: > > > > @@ -65,6 +65,11 @@ BPF_CALL_3(bpf_probe_read, void *, dst, u32, size, > > > const void *, unsafe_ptr) > > > { > > > int ret; >

Re: [PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-19 Thread Alexei Starovoitov
On Thu, Oct 19, 2017 at 03:52:49PM +0100, David Howells wrote: > From: Chun-Yi Lee > > There are some bpf functions can be used to read kernel memory: > bpf_probe_read, bpf_probe_write_user and bpf_trace_printk. These allow > private keys in kernel memory (e.g. the hibernation image signing key)

Re: [PATCH net 0/3] Fix for BPF devmap percpu allocation splat

2017-10-18 Thread Alexei Starovoitov
On Wed, Oct 18, 2017 at 7:22 AM, Daniel Borkmann wrote: > > Higher prio imo would be to make the allocation itself faster > though, I remember we talked about this back in May wrt hashtable, > but I kind of lost track whether there was an update on this in > the mean time. ;-) new percpu allocato

Re: [PATCH net 3/3] bpf: do not test for PCPU_MIN_UNIT_SIZE before percpu allocations

2017-10-17 Thread Alexei Starovoitov
enly assumed __GFP_NOWARN would work, so > no changes needed to their actual __alloc_percpu_gfp() calls > which use the flag already. > > Signed-off-by: Daniel Borkmann Acked-by: Alexei Starovoitov

Re: [PATCH net 2/3] bpf: fix splat for illegal devmap percpu allocation

2017-10-17 Thread Alexei Starovoitov
ed-by: Mark Rutland > Reported-by: Shankara Pailoor > Reported-by: Richard Weinberger > Signed-off-by: Daniel Borkmann > Cc: John Fastabend Acked-by: Alexei Starovoitov

Re: [PATCH net 1/3] mm, percpu: add support for __GFP_NOWARN flag

2017-10-17 Thread Alexei Starovoitov
for __GFP_NOWARN and using it in bpf is much cleaner fix that avoids layering violations. Acked-by: Alexei Starovoitov

<    2   3   4   5   6   7   8   9   10   11   >