Re: [PATCH bpf v3] x86/cpufeature: bpf hack for clang not supporting asm goto

2018-05-10 Thread Gianluca Borello
On Thu, May 10, 2018 at 9:28 AM Borislav Petkov wrote: > As someone already pointed out on IRC, arch/x86/include/asm/cpufeature.h > is solely a kernel header so nothing but kernel should include it. So > forget the userspace breakage "argument". For what is worth, I have the

Re: [RFC bpf] bpf, x64: fix JIT emission for dead code

2018-04-25 Thread Gianluca Borello
On Wed, Apr 25, 2018 at 8:34 AM Daniel Borkmann wrote: > I've applied this fix to bpf tree, thanks Gianluca! Thank you all for the quick review, really appreciated!

[RFC bpf] bpf, x64: fix JIT emission for dead code

2018-04-24 Thread Gianluca Borello
afely translated into a 0xEB instruction with a jump offset of -2. Such fix brings the BPF program in the previous example to complete again in ~9 passes. Fixes: 2a5418a13fcf ("bpf: improve dead code sanitizing") Signed-off-by: Gianluca Borello <g.bore...@gmail.com> --- Hi Posting

Re: Issue accessing task_struct from BPF due to 4.16 stack-protector changes

2018-03-02 Thread Gianluca Borello
On Fri, Mar 2, 2018 at 12:42 PM, Alexei Starovoitov wrote: > > good catch! > I wonder why sched.h is using this flag insead of relying on #defines from > autoconf.h > It could have been using CONFIG_HAVE_CC_STACKPROTECTOR > instead of CONFIG_CC_STACKPROTECTOR, no ?

Issue accessing task_struct from BPF due to 4.16 stack-protector changes

2018-03-02 Thread Gianluca Borello
Hello, While testing bpf-next, I noticed that I was reading garbage when accessing some task_struct members, and the issue seems caused by the recent commit 2bc2f688fdf8 ("Makefile: move stack-protector availability out of Kconfig") which removes CONFIG_CC_STACKPROTECTOR from autoconf.h. When I

[PATCH bpf-next] bpf: fix stacksafe exploration when comparing states

2017-12-23 Thread Gianluca Borello
irst test, without this fix instructions 16 and 17 are replaced with nops instead of being rejected by the verifier. The second test, instead, allows a program to make a potentially illegal read from the stack. Fixes: cc2b14d51053 ("bpf: teach verifier to recognize zero initialized stack")

Re: len = bpf_probe_read_str(); bpf_perf_event_output(... len) == FAIL

2017-11-22 Thread Gianluca Borello
On Tue, Nov 21, 2017 at 2:31 PM, Alexei Starovoitov wrote: > > yeah sorry about this hack. Gianluca reported this issue as well. > Yonghong fixed it for bpf_probe_read only. We will extend > the fix to bpf_probe_read_str() and bpf_perf_event_output() asap. > The

[PATCH net 4/4] bpf: change bpf_perf_event_output arg5 type to ARG_CONST_SIZE_OR_ZERO

2017-11-22 Thread Gianluca Borello
0, buf, len & 0x7fff); No changes to the bpf_perf_event_output helper are necessary since it can handle a case where size is 0, and an empty frame is pushed. Reported-by: Arnaldo Carvalho de Melo <a...@redhat.com> Signed-off-by: Gianluca Borello <g.bore...@gmail.com> Acked-by: Ale

[PATCH net 3/4] bpf: change bpf_probe_read_str arg2 type to ARG_CONST_SIZE_OR_ZERO

2017-11-22 Thread Gianluca Borello
strncpy_from_unsafe itself immediately returns if the size passed is 0. Signed-off-by: Gianluca Borello <g.bore...@gmail.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- kernel/trace/bpf_trace.c | 2 +- 1 file changed,

[PATCH net 2/4] bpf: remove explicit handling of 0 for arg2 in bpf_probe_read

2017-11-22 Thread Gianluca Borello
9e2bc4b2 ("bpf: change helper bpf_probe_read arg2 type to ARG_CONST_SIZE_OR_ZERO") Signed-off-by: Gianluca Borello <g.bore...@gmail.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> Acked-by: Yonghong Song <y...@fb.

[PATCH net 1/4] bpf: introduce ARG_PTR_TO_MEM_OR_NULL

2017-11-22 Thread Gianluca Borello
Also add a new battery of tests that explicitly test the !ARG_PTR_TO_MEM_OR_NULL combination: all the current ones testing the various <NULL, 0> variations are focused on bpf_csum_diff, so cover also other helpers. Signed-off-by: Gianluca Borello <g.bore...@gmail.com> Acked-by:

[PATCH net 0/4] bpf: fix semantics issues with helpers receiving NULL arguments

2017-11-22 Thread Gianluca Borello
for helpers that can receive a <NULL, 0> tuple. By doing so, we can fix the semantics of the other helpers that don't need <NULL, 0> and can just handle , allowing the code to get rid of those checks. Gianluca Borello (4): bpf: introduce ARG_PTR_TO_MEM_OR_NULL bpf: remove

[PATCH net-next] bpf: remove tail_call and get_stackid helper declarations from bpf.h

2017-10-25 Thread Gianluca Borello
ic void (*bpf_tail_call)(void *ctx, void *map, int index); static int (*bpf_get_stackid)(void *ctx, void *map, int flags); Fix this by removing the unused declaration of bpf_tail_call and moving the declaration of bpf_get_stackid in bpf_trace.c, which is the only place where it's needed. Signed-o

[PATCH net-next] bpf: add bpf_probe_read_str helper

2017-01-18 Thread Gianluca Borello
de changes simply leverage the already existent strncpy_from_unsafe() kernel function, which is safe to be called from a bpf program as it is used in bpf_trace_printk(). Signed-off-by: Gianluca Borello <g.bore...@gmail.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel