Re: crash in perf_event_read

2017-01-31 Thread Alexei Starovoitov
> Rework the code to more explicitly deal with event->oncpu being -1. > > Reported-by: Alexei Starovoitov <alexei.starovoi...@gmail.com> > Cc: David Carrillo-Cisneros <davi...@google.com> > Cc: Stephane Eranian <eran...@google.com> > Fixes: d6a2f9035bfc ("

Re: [PATCH net-next v3 04/11] bpf: Use bpf_load_program() from the library

2017-02-07 Thread Alexei Starovoitov
On 2/7/17 1:44 PM, Mickaël Salaün wrote: - union bpf_attr attr; + union bpf_attr attr = {}; - bzero(, sizeof(attr)); I think somebody mentioned that there are compilers out there that don't do it correctly, hence it was done with explicit bzero. Arnaldo, Wang, do you

Re: [PATCH net-next v1 7/7] bpf: Always test unprivileged programs

2017-02-06 Thread Alexei Starovoitov
do_test_single(test, unpriv, , ); + if (!unpriv) { + printf("#%d/p %s ", i, test->descr); + do_test_single(test, false, , ); + } great idea. Acked-by: Alexei Starovoitov <a...@kernel.org> as far as other patches.. we

Re: [PATCH net-next v2 3/3] bpf: Always test unprivileged programs

2017-02-06 Thread Alexei Starovoitov
The geteuid() check is replaced with a capability check. Handling capabilities requires the libcap dependency. Signed-off-by: Mickaël Salaün <m...@digikod.net> Cc: Alexei Starovoitov <a...@fb.com> Cc: Daniel Borkmann <dan...@iogearbox.net> Cc: Shuah Khan <sh...@kernel.org> Acked-b

Re: Potential issues (security and otherwise) with the current cgroup-bpf API

2017-01-22 Thread Alexei Starovoitov
On Thu, Jan 19, 2017 at 08:04:59PM -0800, Andy Lutomirski wrote: > On Thu, Jan 19, 2017 at 6:39 PM, Alexei Starovoitov > <alexei.starovoi...@gmail.com> wrote: > > On Wed, Jan 18, 2017 at 06:29:22PM -0800, Andy Lutomirski wrote: > >> I think it could work by making a sing

Re: [patch] samples/bpf: silence shift wrapping warning

2017-01-22 Thread Alexei Starovoitov
On Sat, Jan 21, 2017 at 07:51:43AM +0300, Dan Carpenter wrote: > max_key is a value in the 0-63 range, so on 32 bit systems the shift > could wrap. > > Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com> Looks fine. I think 'net-next' is ok. Acked-by: Alexei Starovoito

Re: [PATCH] bpf: don't kfree an uninitialized im_node

2017-01-24 Thread Alexei Starovoitov
On Tue, Jan 24, 2017 at 6:16 AM, Colin King wrote: > From: Colin Ian King > > There are some error exit paths to the label 'out' that end up > kfree'ing an uninitialized im_node. Fix this by inititializing > im_node to NULL to avoid kfree'ing

Re: [PATCH 0/6 v3] kvmalloc

2017-01-24 Thread Alexei Starovoitov
On Tue, Jan 24, 2017 at 04:17:52PM +0100, Michal Hocko wrote: > On Thu 12-01-17 16:37:11, Michal Hocko wrote: > > Hi, > > this has been previously posted as a single patch [1] but later on more > > built on top. It turned out that there are users who would like to have > > __GFP_REPEAT semantic.

Re: [patch] samples/bpf: silence shift wrapping warning

2017-01-23 Thread Alexei Starovoitov
On Mon, Jan 23, 2017 at 5:27 AM, Arnaldo Carvalho de Melo <arnaldo.m...@gmail.com> wrote: > Em Sun, Jan 22, 2017 at 02:51:25PM -0800, Alexei Starovoitov escreveu: >> On Sat, Jan 21, 2017 at 07:51:43AM +0300, Dan Carpenter wrote: >> > max_key is a value in the 0-63 ran

crash in perf_event_read

2017-01-30 Thread Alexei Starovoitov
Hi Peter, rarely I'm seeing the following crash: [40196.164255] BUG: unable to handle kernel paging request at a11a [40196.179636] IP: perf_event_read+0xd3/0x1a0 [40196.188669] PGD 82e93a067 [40196.188670] PUD 7e1ddf067 [40196.194629] PMD 0 [40196.200589] [40196.208284] Oops:

Re: [PATCH 0/6 v3] kvmalloc

2017-01-25 Thread Alexei Starovoitov
On Wed, Jan 25, 2017 at 5:21 AM, Michal Hocko <mho...@kernel.org> wrote: > On Wed 25-01-17 14:10:06, Michal Hocko wrote: >> On Tue 24-01-17 11:17:21, Alexei Starovoitov wrote: >> > On Tue, Jan 24, 2017 at 04:17:52PM +0100, Michal Hocko wrote: >> > > On Thu 1

Re: [PATCH v2] virtio_net: fix PAGE_SIZE > 64k

2017-01-24 Thread Alexei Starovoitov
On Tue, Jan 24, 2017 at 7:48 PM, John Fastabend wrote: > > It is a concern on my side. I want XDP and Linux stack to work > reasonably well together. btw the micro benchmarks showed that page per packet approach that xdp took in mlx4 should be 10% slower vs normal

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

2017-02-15 Thread Alexei Starovoitov
On 2/15/17 7:02 PM, Stephen Rothwell wrote: Hi all, On Tue, 14 Feb 2017 09:12:50 +1100 Stephen Rothwell wrote: After merging the net tree, today's linux-next build (powerpc64le perf) failed like this: Warning: tools/include/uapi/linux/bpf.h differs from kernel bpf.c:

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

2017-02-15 Thread Alexei Starovoitov
On 2/15/17 7:27 PM, David Miller wrote: From: Alexei Starovoitov <a...@fb.com> Date: Wed, 15 Feb 2017 19:06:02 -0800 On 2/15/17 7:02 PM, Stephen Rothwell wrote: Hi all, On Tue, 14 Feb 2017 09:12:50 +1100 Stephen Rothwell <s...@canb.auug.org.au> wrote: After merging the net t

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

2017-02-13 Thread Alexei Starovoitov
is not my typical workflow. Joe, can you think of a way to make tools/lib/bpf to use tools/include only? Right now we just pull tools/lib/bpf/bpf.o in samples/bpf/Makefile and that's a hack that caused this issue. samples/bpf/ needs to depend on libbpf.a properly. For the patch: Acked-by: Alexei S

Re: [PATCH v3 10/30] perf clang: Add builtin clang support ant test case

2017-01-17 Thread Alexei Starovoitov
On Tue, Jan 17, 2017 at 5:38 AM, Arnaldo Carvalho de Melo wrote: > > [acme@jouet linux]$ ls -lah /tmp/perf > -rwxr-xr-x. 1 acme acme 4.4M Jan 17 10:29 /tmp/perf > [acme@jouet linux]$ size /tmp/perf >textdata bss dec hex filename > 3954488 622440 23912104

Re: Potential issues (security and otherwise) with the current cgroup-bpf API

2017-01-19 Thread Alexei Starovoitov
On Wed, Jan 18, 2017 at 06:29:22PM -0800, Andy Lutomirski wrote: > I think it could work by making a single socket cgroup controller that > handles all cgroup things that are bound to a socket. Using Such 'socket cgroup controller' would limit usability of the feature to sockets and force all

Re: [PATCH] bpf: update the comment about the length of analysis

2017-03-01 Thread Alexei Starovoitov
the comment to reflect the change. > > Cc: Alexei Starovoitov <a...@kernel.org> > Cc: Daniel Borkmann <dan...@iogearbox.net> > Signed-off-by: Gary Lin <g...@suse.com> Acked-by: Alexei Starovoitov <a...@kernel.org>

[PATCH v2 net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs

2016-08-31 Thread Alexei Starovoitov
rog, since it's assigned only once before it's accessed. Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- include/linux/bpf.h| 4 +++ include/linux/perf_event.h | 2 ++ kernel/events/core.c | 85 +- 3 files changed, 90 i

[PATCH v2 net-next 2/6] bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type

2016-08-31 Thread Alexei Starovoitov
e_data without affecting bpf programs. New fields can be added to the end of struct bpf_perf_event_data in the future. Signed-off-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- include/linux/perf_event.h | 5 include

[PATCH v2 net-next 5/6] samples/bpf: add perf_event+bpf example

2016-08-31 Thread Alexei Starovoitov
for current process and inherited perf_events to children - PERF_COUNT_SW_CPU_CLOCK on all cpus - PERF_COUNT_SW_CPU_CLOCK for current process Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h | 2 + samples/bpf/bpf_

[PATCH v2 net-next 3/6] bpf: perf_event progs should only use preallocated maps

2016-08-31 Thread Alexei Starovoitov
Make sure that BPF_PROG_TYPE_PERF_EVENT programs only use preallocated hash maps, since doing memory allocation in overflow_handler can crash depending on where nmi got triggered. Signed-off-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> ---

[PATCH v2 net-next 6/6] samples/bpf: add sampleip example

2016-08-31 Thread Alexei Starovoitov
From: Brendan Gregg <bgr...@netflix.com> sample instruction pointer and frequency count in a BPF map Signed-off-by: Brendan Gregg <bgr...@netflix.com> Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- samples/bpf/Makefile| 4 + samples/bpf/sam

[PATCH v2 net-next 1/6] bpf: support 8-byte metafield access

2016-08-31 Thread Alexei Starovoitov
programs. They check for 4-byte only ctx access before these conditions are hit. Signed-off-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- kernel/bpf/verifier.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git

[PATCH v2 net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events

2016-08-31 Thread Alexei Starovoitov
as an overflow_handler to sw and hw perf_events. Peter, please review. Patches 5 and 6 are examples from myself and Brendan. v1-v2: fixed issues spotted by Peter and Daniel. Thanks! Alexei Starovoitov (5): bpf: support 8-byte metafield access bpf: introduce BPF_PROG_TYPE_PERF_EVENT program

Re: [PATCH, net-next] perf, bpf: fix conditional call to bpf_overflow_handler

2016-09-06 Thread Alexei Starovoitov
gt; Fixes: aa6a5f3cb2b2 ("perf, bpf: add perf events core support for > BPF_PROG_TYPE_PERF_EVENT programs") > --- > kernel/events/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > I'm not entirely sure if this is the correct solution, please check b

[PATCH v3 net-next 5/6] samples/bpf: add perf_event+bpf example

2016-09-01 Thread Alexei Starovoitov
for current process and inherited perf_events to children - PERF_COUNT_SW_CPU_CLOCK on all cpus - PERF_COUNT_SW_CPU_CLOCK for current process Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h | 2 + samples/bpf/bpf_

[PATCH v3 net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs

2016-09-01 Thread Alexei Starovoitov
rog, since it's assigned only once before it's accessed. Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- include/linux/bpf.h| 4 +++ include/linux/perf_event.h | 4 +++ kernel/events/core.c | 89 +- 3 files changed, 96 i

[PATCH v3 net-next 6/6] samples/bpf: add sampleip example

2016-09-01 Thread Alexei Starovoitov
From: Brendan Gregg <bgr...@netflix.com> sample instruction pointer and frequency count in a BPF map Signed-off-by: Brendan Gregg <bgr...@netflix.com> Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- samples/bpf/Makefile| 4 + samples/bpf/sam

[PATCH v3 net-next 3/6] bpf: perf_event progs should only use preallocated maps

2016-09-01 Thread Alexei Starovoitov
Make sure that BPF_PROG_TYPE_PERF_EVENT programs only use preallocated hash maps, since doing memory allocation in overflow_handler can crash depending on where nmi got triggered. Signed-off-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> ---

[PATCH v3 net-next 1/6] bpf: support 8-byte metafield access

2016-09-01 Thread Alexei Starovoitov
programs. They check for 4-byte only ctx access before these conditions are hit. Signed-off-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- kernel/bpf/verifier.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git

[PATCH v3 net-next 2/6] bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type

2016-09-01 Thread Alexei Starovoitov
e_data without affecting bpf programs. New fields can be added to the end of struct bpf_perf_event_data in the future. Signed-off-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- include/linux/perf_event.h | 5 +++ include

[PATCH v3 net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events

2016-09-01 Thread Alexei Starovoitov
. v2->v3: fixed few more minor issues v1->v2: fixed issues spotted by Peter and Daniel. Thanks! Alexei Starovoitov (5): bpf: support 8-byte metafield access bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type bpf: perf_event progs should only use preallocated maps perf, bpf: add perf

Re: [PATCH v2 net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs

2016-09-01 Thread Alexei Starovoitov
On Thu, Sep 01, 2016 at 10:12:51AM +0200, Peter Zijlstra wrote: > On Wed, Aug 31, 2016 at 02:50:41PM -0700, Alexei Starovoitov wrote: > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > > index 97bfe62f30d7..dcaaaf3ec8e6 100644 > > --- a/include/linux/p

Re: [PATCH net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events

2016-08-29 Thread Alexei Starovoitov
On Mon, Aug 29, 2016 at 12:58:00PM +0200, Peter Zijlstra wrote: > On Fri, Aug 26, 2016 at 07:31:18PM -0700, Alexei Starovoitov wrote: > > Hi Peter, Dave, > > > > this patch set is a follow up to the discussion: > > https://lkml.org/lkml/2016/8/4/304 > > Please do

Re: [PATCH RFC 2/2] rlimits: report resource limits violations

2016-09-07 Thread Alexei Starovoitov
On Wed, Sep 07, 2016 at 01:27:35PM +0300, Yauheni Kaliuta wrote: > The patch instrument different places of resource limits checks with > reporting using the infrastructure from the previous patch. > > Signed-off-by: Yauheni Kaliuta > --- > arch/ia64/kernel/perfmon.c

Re: [PATCH v2 1/5] blk-mq: abstract tag allocation out into scale_bitmap library

2016-09-07 Thread Alexei Starovoitov
On 9/7/16 4:46 PM, Omar Sandoval wrote: From: Omar Sandoval This is a generally useful data structure, so make it available to anyone else who might want to use it. It's also a nice cleanup separating the allocation logic from the rest of the tag handling logic. The code is

Re: [PATCH v2 1/5] blk-mq: abstract tag allocation out into scale_bitmap library

2016-09-07 Thread Alexei Starovoitov
On 9/7/16 5:38 PM, Omar Sandoval wrote: On Wed, Sep 07, 2016 at 05:01:56PM -0700, Alexei Starovoitov wrote: On 9/7/16 4:46 PM, Omar Sandoval wrote: From: Omar Sandoval <osan...@fb.com> This is a generally useful data structure, so make it available to anyone else who might want

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-30 Thread Alexei Starovoitov
t;>> On Sun, Aug 28, 2016 at 2:42 AM, Mickaël Salaün <m...@digikod.net> wrote: > >>>> > >>>> > >>>> On 28/08/2016 10:13, Andy Lutomirski wrote: > >>>>> On Aug 27, 2016 11:14 PM, "Mickaël Salaün" <m...@digikod.net

Re: [PATCH net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs

2016-08-30 Thread Alexei Starovoitov
On Mon, Aug 29, 2016 at 02:17:18PM +0200, Peter Zijlstra wrote: > On Fri, Aug 26, 2016 at 07:31:22PM -0700, Alexei Starovoitov wrote: > > +static int perf_event_set_bpf_handler(struct perf_event *event, u32 > > prog_fd) > > +{ > > + struct bpf_prog *pr

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-30 Thread Alexei Starovoitov
On Tue, Aug 30, 2016 at 02:45:14PM -0700, Andy Lutomirski wrote: > > One might argue that landlock shouldn't be tied to seccomp (in theory, > attached progs could be given access to syscall_get_xyz()), but I proposed lsm is way more powerful than syscall_get_xyz. no need to dumb it down. >

Re: [RFC v3 03/22] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles

2016-09-14 Thread Alexei Starovoitov
place custom checker groups > * simpler userland API > > Signed-off-by: Mickaël Salaün <m...@digikod.net> > Cc: Alexei Starovoitov <a...@kernel.org> > Cc: Andy Lutomirski <l...@amacapital.net> > Cc: Daniel Borkmann <dan...@iogearbox.net> > Cc: David

Re: [RFC v3 07/22] landlock: Handle file comparisons

2016-09-14 Thread Alexei Starovoitov
o anonymous inode) > * replace struct file* with struct path* in map_landlock_handle > * add BPF protos > * fix bpf_landlock_cmp_fs_prop_with_struct_file() > > Signed-off-by: Mickaël Salaün <m...@digikod.net> > Cc: Alexei Starovoitov <a...@kernel.org> > Cc: Andy Lutomirski

Re: [RFC v3 21/22] bpf,landlock: Add optional skb pointer in the Landlock context

2016-09-14 Thread Alexei Starovoitov
On Wed, Sep 14, 2016 at 09:24:14AM +0200, Mickaël Salaün wrote: > This is a proof of concept to expose optional values that could depend > of the process access rights. > > There is two dedicated flags: LANDLOCK_FLAG_ACCESS_SKB_READ and > LANDLOCK_FLAG_ACCESS_SKB_WRITE. Each of them can be

Re: [RFC v3 22/22] samples/landlock: Add sandbox example

2016-09-14 Thread Alexei Starovoitov
On Wed, Sep 14, 2016 at 09:24:15AM +0200, Mickaël Salaün wrote: > Add a basic sandbox tool to create a process isolated from some part of > the system. This can depend of the current cgroup. > > Example with the current process hierarchy (seccomp): > > $ ls /home > user1 > $

Re: [RFC v3 07/22] landlock: Handle file comparisons

2016-09-14 Thread Alexei Starovoitov
On Thu, Sep 15, 2016 at 01:02:22AM +0200, Mickaël Salaün wrote: > > > > I would suggest for the next RFC to do minimal 7 patches up to this point > > with simple example that demonstrates the use case. > > I would avoid all unpriv stuff and all of seccomp for the next RFC as well, > > otherwise I

Re: [RFC v3 03/22] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles

2016-09-14 Thread Alexei Starovoitov
On Thu, Sep 15, 2016 at 01:22:49AM +0200, Mickaël Salaün wrote: > > On 14/09/2016 20:51, Alexei Starovoitov wrote: > > On Wed, Sep 14, 2016 at 09:23:56AM +0200, Mickaël Salaün wrote: > >> This new arraymap looks like a set and brings new properties: > >> * stro

Re: [RFC v3 14/22] bpf/cgroup: Make cgroup_bpf_update() return an error code

2016-09-14 Thread Alexei Starovoitov
On Wed, Sep 14, 2016 at 09:24:07AM +0200, Mickaël Salaün wrote: > This will be useful to support Landlock for the next commits. > > Signed-off-by: Mickaël Salaün <m...@digikod.net> > Cc: Alexei Starovoitov <a...@kernel.org> > Cc: Daniel Borkmann <dan...@iogearb

Re: [PATCH 2/2] bpf samples: update tracex5 sample to use __seccomp_filter

2016-09-24 Thread Alexei Starovoitov
On Sat, Sep 24, 2016 at 02:10:05AM +0530, Naveen N. Rao wrote: > seccomp_phase1() does not exist anymore. Instead, update sample to use > __seccomp_filter(). While at it, set max locked memory to unlimited. > > Signed-off-by: Naveen N. Rao <naveen.n@linux.vnet.ibm.com>

Re: [PATCH 2/3] bpf powerpc: implement support for tail calls

2016-09-24 Thread Alexei Starovoitov
On Sat, Sep 24, 2016 at 12:33:54AM +0200, Daniel Borkmann wrote: > On 09/23/2016 10:35 PM, Naveen N. Rao wrote: > >Tail calls allow JIT'ed eBPF programs to call into other JIT'ed eBPF > >programs. This can be achieved either by: > >(1) retaining the stack setup by the first eBPF program and having

Re: [PATCH 1/2] bpf samples: fix compiler errors with sockex2 and sockex3

2016-09-24 Thread Alexei Starovoitov
linux.vnet.ibm.com> Thanks for the fix. Acked-by: Alexei Starovoitov <a...@kernel.org>

Re: [PATCH v3] bpf: Set register type according to is_valid_access()

2016-09-26 Thread Alexei Starovoitov
VALUE. > >However, this fix is important for future unprivileged eBPF programs > >which could use pointers in their context. > > > >Signed-off-by: Mickaël Salaün <m...@digikod.net> > >Cc: Alexei Starovoitov <a...@kernel.org> > >Cc: Daniel Borkmann

Re: [PATCH 00/14] perf clang: Support compiling BPF script use builtin clang

2016-09-24 Thread Alexei Starovoitov
On Fri, Sep 23, 2016 at 12:49:47PM +, Wang Nan wrote: > This patch set is the first step to implement features I announced > in LinuxCon NA 2016. See page 31 of: > > >

Re: [PATCH trival 1/2] bpf: clean up put_cpu_var usage

2016-09-26 Thread Alexei Starovoitov
On Mon, Sep 26, 2016 at 11:14:50AM -0700, Shaohua Li wrote: > put_cpu_var takes the percpu data, not the data returned from > get_cpu_var. > > This doesn't change the behavior. > > Cc: Tejun Heo <t...@kernel.org> > Cc: Alexei Starovoitov <a...@kernel.org> > Si

Re: [PATCH 1/2] timekeeping: Avoid taking lock in NMI path with CONFIG_DEBUG_TIMEKEEPING

2016-10-04 Thread Alexei Starovoitov
On Tue, Aug 23, 2016 at 04:08:21PM -0700, John Stultz wrote: > When I added some extra sanity checking in timekeeping_get_ns() under > CONFIG_DEBUG_TIMEKEEPING, I missed that the NMI safe __ktime_get_fast_ns() > method was using timekeeping_get_ns(). > > Thus the locking added to the debug checks

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-14 Thread Alexei Starovoitov
On Wed, Sep 14, 2016 at 09:38:16PM -0700, Andy Lutomirski wrote: > On Wed, Sep 14, 2016 at 9:31 PM, Alexei Starovoitov > <alexei.starovoi...@gmail.com> wrote: > > On Wed, Sep 14, 2016 at 09:08:57PM -0700, Andy Lutomirski wrote: > >> On Wed, Sep 14, 2016 at

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-14 Thread Alexei Starovoitov
On Wed, Sep 14, 2016 at 06:25:07PM -0700, Andy Lutomirski wrote: > On Wed, Sep 14, 2016 at 3:11 PM, Mickaël Salaün wrote: > > > > On 14/09/2016 20:27, Andy Lutomirski wrote: > >> On Wed, Sep 14, 2016 at 12:24 AM, Mickaël Salaün wrote: > >>> Add a new flag

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-14 Thread Alexei Starovoitov
On Wed, Sep 14, 2016 at 09:08:57PM -0700, Andy Lutomirski wrote: > On Wed, Sep 14, 2016 at 9:00 PM, Alexei Starovoitov > <alexei.starovoi...@gmail.com> wrote: > > On Wed, Sep 14, 2016 at 07:27:08PM -0700, Andy Lutomirski wrote: > >> >> > > >> >> &

Re: [RFC v3 18/22] cgroup,landlock: Add CGRP_NO_NEW_PRIVS to handle unprivileged hooks

2016-09-14 Thread Alexei Starovoitov
On Wed, Sep 14, 2016 at 07:27:08PM -0700, Andy Lutomirski wrote: > >> > > >> > This RFC handle both cgroup and seccomp approaches in a similar way. I > >> > don't see why building on top of cgroup v2 is a problem. Is there > >> > security issues with delegation? > >> > >> What I mean is: cgroup v2

Re: [PATCH v2] bpf: Set register type according to is_valid_access()

2016-09-22 Thread Alexei Starovoitov
On Thu, Sep 22, 2016 at 09:56:47PM +0200, Mickaël Salaün wrote: > This fix a pointer leak when an unprivileged eBPF program read a pointer > value from the context. Even if is_valid_access() returns a pointer > type, the eBPF verifier replace it with UNKNOWN_VALUE. The register > value containing

lsm naming dilemma. Re: [RFC v3 07/22] landlock: Handle file comparisons

2016-09-19 Thread Alexei Starovoitov
On Thu, Sep 15, 2016 at 11:25:10PM +0200, Mickaël Salaün wrote: > >> Agreed. With this RFC, the Checmate features (i.e. network helpers) > >> should be able to sit on top of Landlock. > > > > I think neither of them should be called fancy names for no technical > > reason. > > We will have only

Re: [PATCH v1] cgroup,bpf: Add access check for cgroup_get_from_fd()

2016-09-19 Thread Alexei Starovoitov
On Tue, Sep 20, 2016 at 12:49:13AM +0200, Mickaël Salaün wrote: > Add security access check for cgroup backed FD. The "cgroup.procs" file > of the corresponding cgroup should be readable to identify the cgroup, > and writable to prove that the current process can manage this cgroup > (e.g. through

[PATCH net-next 1/6] bpf: support 8-byte metafield access

2016-08-26 Thread Alexei Starovoitov
programs. They check for 4-byte only ctx access before these conditions are hit. Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- kernel/bpf/verifier.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index abb61f

[PATCH net-next 6/6] samples/bpf: add sampleip example

2016-08-26 Thread Alexei Starovoitov
From: Brendan Gregg <bgr...@netflix.com> sample instruction pointer and frequency count in a BPF map Signed-off-by: Brendan Gregg <bgr...@netflix.com> Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- samples/bpf/Makefile| 4 + samples/bpf/sam

[PATCH net-next 5/6] samples/bpf: add perf_event+bpf example

2016-08-26 Thread Alexei Starovoitov
for current process and inherited perf_events to children - PERF_COUNT_SW_CPU_CLOCK on all cpus - PERF_COUNT_SW_CPU_CLOCK for current process Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h | 2 + samples/bpf/bpf_

[PATCH net-next 0/6] perf, bpf: add support for bpf in sw/hw perf_events

2016-08-26 Thread Alexei Starovoitov
. Patches 5 and 6 are tests/examples from myself and Brendan. Thanks! Alexei Starovoitov (5): bpf: support 8-byte metafield access bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type bpf: perf_event progs should only use preallocated maps perf, bpf: add perf events core support

[PATCH net-next 4/6] perf, bpf: add perf events core support for BPF_PROG_TYPE_PERF_EVENT programs

2016-08-26 Thread Alexei Starovoitov
rog, since it's assigned only once before it's accessed. Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- include/linux/bpf.h| 4 +++ include/linux/perf_event.h | 2 ++ kernel/events/core.c | 82 +- 3 files changed, 87 i

[PATCH net-next 3/6] bpf: perf_event progs should only use preallocated maps

2016-08-26 Thread Alexei Starovoitov
Make sure that BPF_PROG_TYPE_PERF_EVENT programs only use preallocated hash maps, since doing memory allocation in overflow_handler can crash depending on where nmi got triggered. Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- kernel/bpf/verifier.c | 22 +-

[PATCH net-next 2/6] bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type

2016-08-26 Thread Alexei Starovoitov
e_data without affecting bpf programs. New fields can be added to the end of struct bpf_perf_event_data in the future. Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- include/linux/perf_event.h | 5 include/uapi/linux/Kbuild | 1 + include/uapi/linux/bpf.h

Re: [RFC v2 09/10] landlock: Handle cgroups

2016-08-27 Thread Alexei Starovoitov
On Sat, Aug 27, 2016 at 12:30:36AM -0700, Andy Lutomirski wrote: > > cgroup is the common way to group multiple tasks. > > Without cgroup only parent<->child relationship will be possible, > > which will limit usability of such lsm to a master task that controls > > its children. Such api

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-27 Thread Alexei Starovoitov
On Sat, Aug 27, 2016 at 09:35:14PM +0200, Mickaël Salaün wrote: > > On 27/08/2016 20:06, Alexei Starovoitov wrote: > > On Sat, Aug 27, 2016 at 04:06:38PM +0200, Mickaël Salaün wrote: > >> > >> On 27/08/2016 01:05, Alexei Starovoitov wrote: > >>> On Fri,

Re: [RFC v2 09/10] landlock: Handle cgroups (program types)

2016-08-27 Thread Alexei Starovoitov
On Sat, Aug 27, 2016 at 04:34:55PM +0200, Mickaël Salaün wrote: > > On 27/08/2016 01:05, Alexei Starovoitov wrote: > > On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: > > > >>> As far as safety and type checking that bpf programs has to do, > >&

Re: [RFC v2 09/10] landlock: Handle cgroups (netfilter match)

2016-08-27 Thread Alexei Starovoitov
On Sat, Aug 27, 2016 at 04:19:05PM +0200, Mickaël Salaün wrote: > > On 27/08/2016 01:05, Alexei Starovoitov wrote: > > On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: > >> To sum up, there is four related patchsets: > >> * "Landlock LSM: Un

Re: [RFC v2 09/10] landlock: Handle cgroups (program types)

2016-08-27 Thread Alexei Starovoitov
On Sat, Aug 27, 2016 at 09:55:01PM +0200, Mickaël Salaün wrote: > > On 27/08/2016 20:19, Alexei Starovoitov wrote: > > On Sat, Aug 27, 2016 at 04:34:55PM +0200, Mickaël Salaün wrote: > >> > >> On 27/08/2016 01:05, Alexei Starovoitov wrote: > >>> On Fri,

Re: [RFC v2 09/10] landlock: Handle cgroups (performance)

2016-08-27 Thread Alexei Starovoitov
On Sat, Aug 27, 2016 at 04:06:38PM +0200, Mickaël Salaün wrote: > > On 27/08/2016 01:05, Alexei Starovoitov wrote: > > On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: > >> > >>> > >>> - I don't think such 'for' loop can scale. Th

Re: [RFC v2 09/10] landlock: Handle cgroups

2016-08-26 Thread Alexei Starovoitov
On Fri, Aug 26, 2016 at 05:10:40PM +0200, Mickaël Salaün wrote: > trimming cc list again. When it's too big vger will consider it as spam. > On 26/08/2016 04:14, Alexei Starovoitov wrote: > > On Thu, Aug 25, 2016 at 12:32:44PM +0200, Mickaël Salaün wrote: > >>

Re: [RFC v2 09/10] landlock: Handle cgroups

2016-08-25 Thread Alexei Starovoitov
On Thu, Aug 25, 2016 at 12:32:44PM +0200, Mickaël Salaün wrote: > Add an eBPF function bpf_landlock_cmp_cgroup_beneath(opt, map, map_op) > to compare the current process cgroup with a cgroup handle, The handle > can match the current cgroup if it is the same or a child. This allows > to make

Re: [PATCH trival -resend 1/2] bpf: clean up put_cpu_var usage

2016-09-27 Thread Alexei Starovoitov
On Tue, Sep 27, 2016 at 08:42:41AM -0700, Shaohua Li wrote: > put_cpu_var takes the percpu data, not the data returned from > get_cpu_var. > > This doesn't change the behavior. > > Cc: Tejun Heo <t...@kernel.org> > Cc: Alexei Starovoitov <a...@kernel.org> > Si

Re: [PATCH 00/14] perf clang: Support compiling BPF script use builtin clang

2016-09-26 Thread Alexei Starovoitov
On Mon, Sep 26, 2016 at 09:49:30AM +0800, Wangnan (F) wrote: > > > On 2016/9/24 23:16, Alexei Starovoitov wrote: > >On Fri, Sep 23, 2016 at 12:49:47PM +, Wang Nan wrote: > >>This patch set is the first step to implement features I announced > >>

Re: ftrace module init race/bug

2016-11-07 Thread Alexei Starovoitov
On Mon, Nov 07, 2016 at 03:08:41PM -0500, Steven Rostedt wrote: > On Mon, 7 Nov 2016 11:46:24 -0800 > Alexei Starovoitov <alexei.starovoi...@gmail.com> wrote: > > > Hi Steven, > > > > I'm debugging the following spew: > > > > [ 7139.111213] WARNING

[PATCH] tracing: ignore FTRACE_FL_DISABLED while walking dyn_ftrace records

2016-11-07 Thread Alexei Starovoitov
t's similar to what __ftrace_hash_rec_update() is already doing. Signed-off-by: Alexei Starovoitov <a...@kernel.org> --- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 2050a7652a86..326498baab

Re: [RESEND][PATCH v4] cgroup: Use CAP_SYS_RESOURCE to allow a process to migrate other tasks between cgroups

2016-11-08 Thread Alexei Starovoitov
On Tue, Nov 08, 2016 at 03:51:40PM -0800, Andy Lutomirski wrote: > On Tue, Nov 8, 2016 at 3:28 PM, John Stultz wrote: > > This patch adds logic to allows a process to migrate other tasks > > between cgroups if they have CAP_SYS_RESOURCE. > > > > In Android (where this

ftrace module init race/bug

2016-11-07 Thread Alexei Starovoitov
Hi Steven, I'm debugging the following spew: [ 7139.111213] WARNING: CPU: 8 PID: 856649 at kernel/trace/ftrace.c:2747 ftrace_shutdown+0x263/0x270 [ 7139.753185] 881fc59eba40 814717d1 [ 7139.817019] 881fc59eba80

Re: [PATCH 00/34] perf clang: Builtin clang and perfhook support

2016-11-14 Thread Alexei Starovoitov
On Mon, Nov 14, 2016 at 9:03 PM, Wangnan (F) <wangn...@huawei.com> wrote: > > > On 2016/11/15 12:57, Alexei Starovoitov wrote: >> >> On Mon, Nov 14, 2016 at 8:05 PM, Wang Nan <wangn...@huawei.com> wrote: >>> >>> This is version 2 of perf

Re: [PATCH 00/34] perf clang: Builtin clang and perfhook support

2016-11-14 Thread Alexei Starovoitov
On Mon, Nov 14, 2016 at 8:05 PM, Wang Nan wrote: > This is version 2 of perf builtin clang patch series. Compare to v1, > add an exciting feature: jit compiling perf hook functions. This > features allows script writer report result through BPF map in a > customized way.

sendfile from 9p fs into af_alg

2016-11-22 Thread Alexei Starovoitov
Hi Al, it seems the following commit 523ac9afc73a ("switch default_file_splice_read() to use of pipe-backed iov_iter") breaks sendfile from 9p fs into af_alg socket. sendfile into af_alg is used by iproute2/tc. I'm not sure whether it's 9p or crypto or vfs problem, but happy to test any

Re: sendfile from 9p fs into af_alg

2016-11-22 Thread Alexei Starovoitov
On Wed, Nov 23, 2016 at 04:46:26AM +, Al Viro wrote: > On Tue, Nov 22, 2016 at 07:58:29PM -0800, Alexei Starovoitov wrote: > > Hi Al, > > > > it seems the following commit 523ac9afc73a ("switch > > default_file_splice_read() to use of pipe-backed iov_iter&

Re: [PATCH] bpf/samples: Fix PT_REGS_IP on s390x and use it

2016-11-23 Thread Alexei Starovoitov
des of that also fix the macro for s390x and use psw.addr from pt_regs. > > Reported-by: Zvonko Kosic <zvonko.ko...@de.ibm.com> > Signed-off-by: Michael Holzheu <holz...@linux.vnet.ibm.com> Looks good. Acked-by: Alexei Starovoitov <a...@kernel.org> Please resubmit it to net-next and cc Dave. note that my @plumgrid email no longer vaid.

Re: [PATCH v3 25/30] perf clang jit: Allow jitted perf hook access BPF maps

2016-11-26 Thread Alexei Starovoitov
(name, proto) { \ > + int map_fd = get_bpf_map_fd(ctx, map); \ > + \ > + if (map_fd < 0) \ > +

Re: [PATCH v3 01/30] tools lib bpf: Add missing BPF functions

2016-11-26 Thread Alexei Starovoitov
On Sat, Nov 26, 2016 at 07:03:25AM +, Wang Nan wrote: > Add more BPF map operations to libbpf. Also add bpf_obj_{pin,get}(). They > can be used on not only BPF maps but also BPF programs. > > Signed-off-by: Wang Nan <wangn...@huawei.com> > Cc: Alexei Starovoitov <a.

Re: [PATCH v3 02/30] tools lib bpf: Add private field for bpf_object

2016-11-26 Thread Alexei Starovoitov
On Sat, Nov 26, 2016 at 07:03:26AM +, Wang Nan wrote: > Similar to other classes defined in libbpf.h (map and program), allow > 'object' class has its own private data. > > Signed-off-by: Wang Nan <wangn...@huawei.com> > Cc: Alexei Starovoitov <a...@fb.com> >

Re: [PATCH v3 03/30] tools lib bpf: Retrive bpf_map through offset of bpf_map_def

2016-11-26 Thread Alexei Starovoitov
return >maps[i]; > + } > + return ERR_PTR(-ENOENT); > +} Acked-by: Alexei Starovoitov <a...@kernel.org>

Re: [PATCH v3 10/30] perf clang: Add builtin clang support ant test case

2016-11-26 Thread Alexei Starovoitov
On Sat, Nov 26, 2016 at 07:03:34AM +, Wang Nan wrote: > Add basic clang support in clang.cpp and test__clang() testcase. The > first testcase checks if builtin clang is able to generate LLVM IR. > > tests/clang.c is a proxy. Real testcase resides in > utils/c++/clang-test.cpp in c++ and

Re: [PATCH v3 14/30] perf clang: Support compile IR to BPF object and add testcase

2016-11-26 Thread Alexei Starovoitov
On Sat, Nov 26, 2016 at 07:03:38AM +, Wang Nan wrote: > getBPFObjectFromModule() is introduced to compile LLVM IR(Module) > to BPF object. Add new testcase for it. > > Test result: > $ ./buildperf/perf test -v clang > 51: Test builtin clang support : >

Re: [PATCH v3 20/30] perf clang jit: add PerfModule::doJIT to JIT perfhook functions

2016-11-26 Thread Alexei Starovoitov
(); > LLVMInitializeBPFTargetMC(); > LLVMInitializeBPFAsmPrinter(); > + > + llvm::InitializeNativeTarget(); > + llvm::InitializeNativeTargetAsmPrinter(); > + llvm::InitializeNativeTargetAsmParser(); Looks great. I bet a lot of people reading perf code won't be able to understand what you're doing here. Could you please add a design doc on how perf<->clang/llvm interaction is done. Acked-by: Alexei Starovoitov <a...@kernel.org>

Re: [PATCH v3 26/30] perf clang: Link BPF functions declaration into perf

2016-11-26 Thread Alexei Starovoitov
Carvalho de Melo <a...@redhat.com> > Cc: Alexei Starovoitov <a...@fb.com> > Cc: He Kuang <heku...@huawei.com> > Cc: Jiri Olsa <jo...@kernel.org> > Cc: Zefan Li <lize...@huawei.com> > Cc: pi3or...@163.com > --- > tools/pe

Re: [PATCH v3 19/30] perf clang jit: Insignt BPF and JIT functions in a Module

2016-11-26 Thread Alexei Starovoitov
> + for (llvm::Function *F : BPFFunctions) > + F->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); > + for (llvm::Function *F : JITFunctions) > + F->setLinkage(llvm::GlobalValue::ExternalLinkage); > + > +} Nice trick. Please document it in the perf+llvm design doc. Acked-by: Alexei Starovoitov <a...@kernel.org>

Re: sendfile from 9p fs into af_alg

2016-11-23 Thread Alexei Starovoitov
On Wed, Nov 23, 2016 at 06:16:28AM +, Al Viro wrote: > On Tue, Nov 22, 2016 at 08:55:59PM -0800, Alexei Starovoitov wrote: > > On Wed, Nov 23, 2016 at 04:46:26AM +, Al Viro wrote: > > > On Tue, Nov 22, 2016 at 07:58:29PM -0800, Alexei Starovoitov wr

Re: sendfile from 9p fs into af_alg

2016-11-23 Thread Alexei Starovoitov
On Wed, Nov 23, 2016 at 03:53:01PM +, Al Viro wrote: > On Wed, Nov 23, 2016 at 12:58:11AM -0800, Alexei Starovoitov wrote: > > > if I read it correctly 9p actually responded with 8192 bytes of requests... > > whereas the file size was 9624. > > For large

Re: [PATCH v3 14/30] perf clang: Support compile IR to BPF object and add testcase

2016-11-28 Thread Alexei Starovoitov
On Mon, Nov 28, 2016 at 06:31:11PM +0800, Wangnan (F) wrote: > > > On 2016/11/28 14:32, Wangnan (F) wrote: > > > > > >On 2016/11/27 1:25, Alexei Starovoitov wrote: > >>On Sat, Nov 26, 2016 at 07:03:38AM +, Wang Nan wrote: > >>>getBPFObjectFrom

<    10   11   12   13   14   15   16   17   18   19   >