Re: [PATCH bpf] bpf, riscv: clear target register high 32-bits for and/or/xor on ALU32

2019-05-21 Thread Daniel Borkmann
On 05/21/2019 03:46 PM, Björn Töpel wrote: > When using 32-bit subregisters (ALU32), the RISC-V JIT would not clear > the high 32-bits of the target register and therefore generate > incorrect code. > > E.g., in the following code: > > $ cat test.c > unsigned int f(unsigned long long a, >

Re: [PATCH] Documentation/networking: fix af_xdp.rst Sphinx warnings

2019-05-21 Thread Daniel Borkmann
etworking/af_xdp.rst:326: WARNING: Literal block expected; > none found. > > Fixes: 0f4a9b7d4ecb ("xsk: add FAQ to facilitate for first time users") > > Signed-off-by: Randy Dunlap > Cc: Magnus Karlsson > Cc: Daniel Borkmann Applied, thanks!

Re: [PATCH bpf] bpf: fix out-of-bounds read in __bpf_skc_lookup

2019-05-21 Thread Daniel Borkmann
On 05/21/2019 09:52 AM, Lorenz Bauer wrote: > __bpf_skc_lookup takes a socket tuple and the length of the > tuple as an argument. Based on the length, it decides which > address family to pass to the helper function sk_lookup. > > In case of AF_INET6, it fails to verify that the length > of the tu

Re: [PATCH bpf] bpf: Check sk_fullsock() before returning from bpf_sk_lookup()

2019-05-21 Thread Daniel Borkmann
On 05/17/2019 11:21 PM, Martin KaFai Lau wrote: > The BPF_FUNC_sk_lookup_xxx helpers return RET_PTR_TO_SOCKET_OR_NULL. > Meaning a fullsock ptr and its fullsock's fields in bpf_sock can be > accessed, e.g. type, protocol, mark and priority. > Some new helper, like bpf_sk_storage_get(), also expects

Re: [PATCH] samples: bpf: fix: change the buffer size for read()

2019-05-21 Thread Daniel Borkmann
On 05/19/2019 11:05 AM, Chang-Hsien Tsai wrote: > If the trace for read is larger than 4096, > the return value sz will be 4096. > This results in off-by-one error on buf. > > static char buf[4096]; > ssize_t sz; > > sz = read(trace_fd, buf, sizeof(buf)); > if (sz > 0) { >

bpf-next is OPEN

2019-05-21 Thread Daniel Borkmann
Merge window is closed, so new round begins as usual. Thanks everyone, Daniel

Re: [PATCH net] net: sched: sch_ingress: do not report ingress filter info in egress path

2019-05-22 Thread Daniel Borkmann
On 05/22/2019 12:20 PM, Lorenzo Bianconi wrote: >> On Tue, 2019-05-21 at 14:59 +0200, Lorenzo Bianconi wrote: >>> Currently if we add a filter to the ingress qdisc (e.g matchall) the >>> filter data are reported even in the egress path. The issue can be >>> triggered with the following reproducer:

Re: [PATCH bpf] bpf, riscv: clear target register high 32-bits for and/or/xor on ALU32

2019-05-23 Thread Daniel Borkmann
On 05/21/2019 04:12 PM, Björn Töpel wrote: > On Tue, 21 May 2019 at 16:02, Daniel Borkmann wrote: >> On 05/21/2019 03:46 PM, Björn Töpel wrote: >>> When using 32-bit subregisters (ALU32), the RISC-V JIT would not clear >>> the high 32-bits of the target regi

Re: [PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor

2019-05-23 Thread Daniel Borkmann
On 05/23/2019 08:38 AM, Y Song wrote: > On Wed, May 22, 2019 at 1:46 PM Björn Töpel wrote: >> On Wed, 22 May 2019 at 20:13, Y Song wrote: >>> On Wed, May 22, 2019 at 2:25 AM Björn Töpel wrote: Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the

Re: [bpf PATCH] bpf: sockmap, restore sk_write_space when psock gets dropped

2019-05-23 Thread Daniel Borkmann
On 05/22/2019 12:01 PM, Jakub Sitnicki wrote: > Once psock gets unlinked from its sock (sk_psock_drop), user-space can > still trigger a call to sk->sk_write_space by setting TCP_NOTSENT_LOWAT > socket option. This causes a null-ptr-deref because we try to read > psock->saved_write_space from sk_ps

Re: [PATCH v2 bpf-next 0/3] bpf: increase jmp sequence limit

2019-05-23 Thread Daniel Borkmann
On 05/22/2019 05:14 AM, Alexei Starovoitov wrote: > Patch 1 - jmp sequence limit > Patch 2 - improve existing tests > Patch 3 - add pyperf-based realistic bpf program that takes advantage > of higher limit and use it as a stress test > > v1->v2: fixed nit in patch 3. added Andrii's acks > > Alexe

Re: [PATCH bpf-next v2 1/3] bpf: implement bpf_send_signal() helper

2019-05-23 Thread Daniel Borkmann
On 05/22/2019 07:39 AM, Yonghong Song wrote: > This patch tries to solve the following specific use case. > > Currently, bpf program can already collect stack traces > through kernel function get_perf_callchain() > when certain events happens (e.g., cache miss counter or > cpu clock counter overfl

Re: [PATCH bpf-next v2 1/3] bpf: implement bpf_send_signal() helper

2019-05-23 Thread Daniel Borkmann
On 05/23/2019 05:58 PM, Yonghong Song wrote: > On 5/23/19 8:41 AM, Daniel Borkmann wrote: >> On 05/22/2019 07:39 AM, Yonghong Song wrote: >>> This patch tries to solve the following specific use case. >>> >>> Currently, bpf program can already collect stac

Re: [PATCH bpf-next v2 1/3] bpf: implement bpf_send_signal() helper

2019-05-23 Thread Daniel Borkmann
On 05/23/2019 11:30 PM, Yonghong Song wrote: > On 5/23/19 2:07 PM, Yonghong Song wrote: >> On 5/23/19 9:28 AM, Daniel Borkmann wrote: >>> On 05/23/2019 05:58 PM, Yonghong Song wrote: >>>> On 5/23/19 8:41 AM, Daniel Borkmann wrote: >>>>> On 05/22/20

Re: [PATCH] bpf: sockmap, fix use after free from sleep in psock backlog workqueue

2019-05-24 Thread Daniel Borkmann
On 05/23/2019 05:48 PM, John Fastabend wrote: > Backlog work for psock (sk_psock_backlog) might sleep while waiting > for memory to free up when sending packets. However, while sleeping > the socket may be closed and removed from the map by the user space > side. > > This breaks an assumption in s

Re: [PATCH v2 bpf-next 0/3] bpf: optimize explored_states

2019-05-24 Thread Daniel Borkmann
On 05/22/2019 05:17 AM, Alexei Starovoitov wrote: > Convert explored_states array into hash table and use simple hash to > reduce verifier peak memory consumption for programs with bpf2bpf calls. > More details in patch 3. > > v1->v2: fixed Jakub's small nit in patch 1 > > Alexei Starovoitov (3):

Re: [RFC net-next 1/1] net: sched: protect against loops in TC filter hooks

2019-05-24 Thread Daniel Borkmann
On 05/24/2019 06:05 PM, John Hurley wrote: > TC hooks allow the application of filters and actions to packets at both > ingress and egress of the network stack. It is possible, with poor > configuration, that this can produce loops whereby an ingress hook calls > a mirred egress action that has an

Re: [PATCH v2] bpf: sockmap, fix use after free from sleep in psock backlog workqueue

2019-05-24 Thread Daniel Borkmann
On 05/24/2019 05:01 PM, John Fastabend wrote: > Backlog work for psock (sk_psock_backlog) might sleep while waiting > for memory to free up when sending packets. However, while sleeping > the socket may be closed and removed from the map by the user space > side. > > This breaks an assumption in s

Re: [PATCH bpf-next v2 1/3] bpf: implement bpf_send_signal() helper

2019-05-24 Thread Daniel Borkmann
On 05/24/2019 01:54 AM, Yonghong Song wrote: > > > On 5/23/19 4:08 PM, Daniel Borkmann wrote: >> On 05/23/2019 11:30 PM, Yonghong Song wrote: >>> On 5/23/19 2:07 PM, Yonghong Song wrote: >>>> On 5/23/19 9:28 AM, Daniel Borkmann wrote: >>>>> On

Re: [PATCH bpf-next v5 0/3] bpf: implement bpf_send_signal() helper

2019-05-24 Thread Daniel Borkmann
On 05/23/2019 11:47 PM, Yonghong Song wrote: > This patch tries to solve the following specific use case. > > Currently, bpf program can already collect stack traces > through kernel function get_perf_callchain() > when certain events happens (e.g., cache miss counter or > cpu clock counter overf

Re: [PATCH bpf-next v5 1/3] bpf: implement bpf_send_signal() helper

2019-05-24 Thread Daniel Borkmann
On 05/23/2019 11:47 PM, Yonghong Song wrote: > This patch tries to solve the following specific use case. > > Currently, bpf program can already collect stack traces > through kernel function get_perf_callchain() > when certain events happens (e.g., cache miss counter or > cpu clock counter overfl

Re: [PATCH bpf-next v5 1/3] bpf: implement bpf_send_signal() helper

2019-05-24 Thread Daniel Borkmann
On 05/24/2019 11:39 PM, Daniel Borkmann wrote: > On 05/23/2019 11:47 PM, Yonghong Song wrote: >> This patch tries to solve the following specific use case. >> >> Currently, bpf program can already collect stack traces >> through kernel function get_perf_callchain() >

Re: [PATCH bpf-next v5 1/3] bpf: implement bpf_send_signal() helper

2019-05-24 Thread Daniel Borkmann
On 05/25/2019 12:20 AM, Yonghong Song wrote: > On 5/24/19 2:39 PM, Daniel Borkmann wrote: >> On 05/23/2019 11:47 PM, Yonghong Song wrote: >>> This patch tries to solve the following specific use case. >>> >>> Currently, bpf program can already collect stac

Re: [PATCH bpf-next v5 1/3] bpf: implement bpf_send_signal() helper

2019-05-24 Thread Daniel Borkmann
On 05/25/2019 12:23 AM, Yonghong Song wrote: > On 5/24/19 2:59 PM, Daniel Borkmann wrote: >> On 05/24/2019 11:39 PM, Daniel Borkmann wrote: >>> On 05/23/2019 11:47 PM, Yonghong Song wrote: >>>> This patch tries to solve the following specific use case. >>>&g

Re: [PATCH bpf-next] bpftool: auto-complete BTF IDs for btf dump

2019-05-28 Thread Daniel Borkmann
On 05/26/2019 02:01 AM, Andrii Nakryiko wrote: > Auto-complete BTF IDs for `btf dump id` sub-command. List of possible BTF > IDs is scavenged from loaded BPF programs that have associated BTFs, as > there is currently no API in libbpf to fetch list of all BTFs in the > system. > > Suggested-by: Qu

Re: [PATCH bpf-next] bpf: check signal validity in nmi for bpf_send_signal() helper

2019-05-28 Thread Daniel Borkmann
On 05/25/2019 08:57 PM, Yonghong Song wrote: > Commit 8b401f9ed244 ("bpf: implement bpf_send_signal() helper") > introduced bpf_send_signal() helper. If the context is nmi, > the sending signal work needs to be deferred to irq_work. > If the signal is invalid, the error will appear in irq_work > an

Re: [PATCH] [PATCH bpf] style fix in while(!feof()) loop

2019-05-28 Thread Daniel Borkmann
On 05/26/2019 12:32 PM, Chang-Hsien Tsai wrote: > use fgets() as the while loop condition. > > Signed-off-by: Chang-Hsien Tsai Applied, thanks!

Re: [PATCH bpf-next v3 0/3] tools: bpftool: add an option for debug output from libbpf and verifier

2019-05-28 Thread Daniel Borkmann
On 05/24/2019 12:36 PM, Quentin Monnet wrote: > Hi, > This series adds an option to bpftool to make it print additional > information via libbpf and the kernel verifier when attempting to load > programs. > > A new API function is added to libbpf in order to pass the log_level from > bpftool with

Re: [PATCH bpf-next] selftests/bpf: fail test_tunnel.sh if subtests fail

2019-05-28 Thread Daniel Borkmann
On 05/25/2019 12:28 AM, Stanislav Fomichev wrote: > Right now test_tunnel.sh always exits with success even if some > of the subtests fail. Since the output is very verbose, it's > hard to spot the issues with subtests. Let's fail the script > if any subtest fails. > > Signed-off-by: Stanislav Fom

Re: [PATCH v2] samples: bpf: fix style in bpf_load

2019-05-28 Thread Daniel Borkmann
On 05/23/2019 09:24 AM, Daniel T. Lee wrote: > This commit fixes style problem in samples/bpf/bpf_load.c > > Styles that have been changed are: > - Magic string use of 'DEBUGFS' > - Useless zero initialization of a global variable > - Minor style fix with whitespace > > Signed-off-by: Daniel T

Re: [PATCH bpf 0/2] selftests: bpf: more sub-register zero extension unit tests

2019-05-29 Thread Daniel Borkmann
On 05/29/2019 11:57 AM, Jiong Wang wrote: > JIT back-ends need to guarantee high 32-bit cleared whenever one eBPF insn > write low 32-bit sub-register only. It is possible that some JIT back-ends > have failed doing this and are silently generating wrong image. > > This set completes the unit test

Re: [PATCH bpf-next] libbpf: prevent overwriting of log_level in bpf_object__load_progs()

2019-05-29 Thread Daniel Borkmann
On 05/29/2019 11:23 AM, Quentin Monnet wrote: > There are two functions in libbpf that support passing a log_level > parameter for the verifier for loading programs: > bpf_object__load_xattr() and bpf_load_program_xattr(). Both accept an > attribute object containing the log_level, and apply it to

Re: [PATCH bpf-next] selftests/bpf: fix compilation error for flow_dissector.c

2019-05-29 Thread Daniel Borkmann
On 05/29/2019 11:48 AM, Alan Maguire wrote: > When building the tools/testing/selftest/bpf subdirectory, > (running both a local directory "make" and a > "make -C tools/testing/selftests/bpf") I keep hitting the > following compilation error: > > prog_tests/flow_dissector.c: In function ‘create_ta

Re: [PATCH bpf v2] selftests: bpf: fix compiler warning

2019-05-29 Thread Daniel Borkmann
On 05/28/2019 09:02 PM, Alakesh Haloi wrote: > Add missing header file following compiler warning > > prog_tests/flow_dissector.c: In function ‘tx_tap’: > prog_tests/flow_dissector.c:175:9: warning: implicit declaration of function > ‘writev’; did you mean ‘write’? [-Wimplicit-function-declaratio

Re: [PATCH bpf-next v4 1/4] bpf: remove __rcu annotations from bpf_prog_array

2019-05-29 Thread Daniel Borkmann
On 05/28/2019 11:14 PM, Stanislav Fomichev wrote: > Drop __rcu annotations and rcu read sections from bpf_prog_array > helper functions. They are not needed since all existing callers > call those helpers from the rcu update side while holding a mutex. > This guarantees that use-after-free could no

Re: [PATCH bpf-next v2] libbpf: prevent overwriting of log_level in bpf_object__load_progs()

2019-05-29 Thread Daniel Borkmann
On 05/29/2019 04:26 PM, Quentin Monnet wrote: > There are two functions in libbpf that support passing a log_level > parameter for the verifier for loading programs: > bpf_object__load_xattr() and bpf_prog_load_xattr(). Both accept an > attribute object containing the log_level, and apply it to the

Re: [PATCH v2 bpf-next 0/9] libbpf random fixes

2019-05-29 Thread Daniel Borkmann
On 05/29/2019 07:36 PM, Andrii Nakryiko wrote: > This patch set is a collection of unrelated fixes for libbpf. > > Patch #1 fixes detection of corrupted BPF section w/ instructions. > Patch #2 fixes possible errno clobbering. > Patch #3 simplifies endianness check and brings it in line with few ot

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Daniel Borkmann
On 06/03/2019 10:39 AM, Björn Töpel wrote: > On Sat, 1 Jun 2019 at 20:12, Jonathan Lemon wrote: >> On 31 May 2019, at 2:42, Björn Töpel wrote: >>> From: Björn Töpel >>> >>> All XDP capable drivers need to implement the XDP_QUERY_PROG{,_HW} >>> command of ndo_bpf. The query code is fairly generic.

Re: [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-06-04 Thread Daniel Borkmann
On 06/03/2019 06:38 PM, Jonathan Lemon wrote: > Currently, the AF_XDP code uses a separate map in order to > determine if an xsk is bound to a queue. Instead of doing this, > have bpf_map_lookup_elem() return the queue_id, as a way of > indicating that there is a valid entry at the map index. > >

Re: [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-06-04 Thread Daniel Borkmann
On 06/04/2019 04:54 PM, Daniel Borkmann wrote: > On 06/03/2019 06:38 PM, Jonathan Lemon wrote: >> Currently, the AF_XDP code uses a separate map in order to >> determine if an xsk is bound to a queue. Instead of doing this, >> have bpf_map_lookup_elem() return the

Re: [PATCH bpf] selftests/bpf: move test_lirc_mode2_user to TEST_GEN_PROGS_EXTENDED

2019-06-05 Thread Daniel Borkmann
On 06/04/2019 04:35 AM, Hangbin Liu wrote: > test_lirc_mode2_user is included in test_lirc_mode2.sh test and should > not be run directly. > > Fixes: 6bdd533cee9a ("bpf: add selftest for lirc_mode2 type program") > Signed-off-by: Hangbin Liu Applied, thanks!

[PATCH bpf 1/2] bpf: fix unconnected udp hooks

2019-06-05 Thread Daniel Borkmann
ressed in future through a different bpf_attach_type such that this case can be distinguished from the regular recvmsg paths, for example. Fixes: 1cedee13d25a ("bpf: Hooks for sys_sendmsg") Signed-off-by: Daniel Borkmann Cc: Andrey Ignatov Cc: Martynas Pumputis --- include/linux/

[PATCH bpf 2/2] bpf: add further msg_name rewrite tests to test_sock_addr

2019-06-05 Thread Daniel Borkmann
ok .. [PASS] Test case: recvmsg6: return code !ok .. [PASS] Test case: recvmsg4: rewrite IP & port (asm) .. [PASS] Test case: recvmsg6: rewrite IP & port (asm) .. [PASS] [...] Signed-off-by: Daniel Borkmann --- tools/testing/selftests/bpf/test_sock_addr.c | 213 +++

Re: [PATCH bpf 1/2] bpf: fix unconnected udp hooks

2019-06-05 Thread Daniel Borkmann
On 06/06/2019 01:54 AM, Martin Lau wrote: > On Wed, Jun 05, 2019 at 10:40:49PM +0200, Daniel Borkmann wrote: >> Intention of cgroup bind/connect/sendmsg BPF hooks is to act transparently >> to applications as also stated in original motivation in 7828f20e3779 ("Merge >&g

Re: [PATCH bpf-next v2] samples: bpf: print a warning about headers_install

2019-06-05 Thread Daniel Borkmann
On 06/06/2019 01:47 AM, Jakub Kicinski wrote: > It seems like periodically someone posts patches to "fix" > header includes. The issue is that samples expect the > include path to have the uAPI headers (from usr/) first, > and then tools/ headers, so that locally installed uAPI > headers take prec

Re: [PATCH bpf 1/2] bpf: fix unconnected udp hooks

2019-06-05 Thread Daniel Borkmann
On 06/06/2019 02:13 AM, Alexei Starovoitov wrote: > On Wed, Jun 5, 2019 at 5:09 PM Daniel Borkmann wrote: >> >>>> tools/bpf/bpftool/cgroup.c | 5 - >>>> tools/include/uapi/linux/bpf.h | 2 ++ >>> Should the bpf.h sync to tools/ be in a separate

[PATCH bpf v2 2/4] bpf: sync tooling uapi header

2019-06-06 Thread Daniel Borkmann
Sync BPF uapi header in order to pull in BPF_CGROUP_UDP{4,6}_RECVMSG attach types. This is done and preferred as an extra patch in order to ease sync of libbpf. Signed-off-by: Daniel Borkmann --- tools/include/uapi/linux/bpf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include

[PATCH bpf v2 0/4] Fix unconnected bpf cgroup hooks

2019-06-06 Thread Daniel Borkmann
lit off uapi header sync and bpftool bits (Martin, Alexei) - Added missing bpftool doc and bash completion as well Daniel Borkmann (4): bpf: fix unconnected udp hooks bpf: sync tooling uapi header bpf, bpftool: enable recvmsg attach types bpf: add further msg_name rewrite tests

[PATCH bpf v2 4/4] bpf: add further msg_name rewrite tests to test_sock_addr

2019-06-06 Thread Daniel Borkmann
ok .. [PASS] Test case: recvmsg6: return code !ok .. [PASS] Test case: recvmsg4: rewrite IP & port (asm) .. [PASS] Test case: recvmsg6: rewrite IP & port (asm) .. [PASS] [...] Signed-off-by: Daniel Borkmann --- tools/testing/selftests/bpf/test_sock_addr.c | 213 +

[PATCH bpf v2 3/4] bpf, bpftool: enable recvmsg attach types

2019-06-06 Thread Daniel Borkmann
Trivial patch to bpftool in order to complete enabling attaching programs to BPF_CGROUP_UDP{4,6}_RECVMSG. Signed-off-by: Daniel Borkmann --- tools/bpf/bpftool/Documentation/bpftool-cgroup.rst | 6 +- tools/bpf/bpftool/Documentation/bpftool-prog.rst | 2 +- tools/bpf/bpftool/bash

[PATCH bpf v2 1/4] bpf: fix unconnected udp hooks

2019-06-06 Thread Daniel Borkmann
better addressed in future through a different bpf_attach_type such that this case can be distinguished from the regular recvmsg paths, for example. Fixes: 1cedee13d25a ("bpf: Hooks for sys_sendmsg") Signed-off-by: Daniel Borkmann Cc: Andrey Ignatov Cc: Martin KaFai Lau Acke

Re: [PATCH net-next v2 1/2] bpf_xdp_redirect_map: Add flag to return XDP_PASS on map lookup failure

2019-06-06 Thread Daniel Borkmann
On 06/06/2019 03:24 PM, Toke Høiland-Jørgensen wrote: > From: Toke Høiland-Jørgensen > > The bpf_redirect_map() helper used by XDP programs doesn't return any > indication of whether it can successfully redirect to the map index it was > given. Instead, BPF programs have to track this themselves,

Re: [PATCH net-next v2 1/2] bpf_xdp_redirect_map: Add flag to return XDP_PASS on map lookup failure

2019-06-06 Thread Daniel Borkmann
On 06/06/2019 08:15 PM, Jonathan Lemon wrote: > On 6 Jun 2019, at 9:15, Toke Høiland-Jørgensen wrote: >> Alexei Starovoitov writes: >>> On Thu, Jun 6, 2019 at 8:51 AM Daniel Borkmann wrote: >>>> On 06/06/2019 03:24 PM, Toke Høiland-Jørgensen wrote: >

Re: [RFC PATCH bpf-next 6/8] libbpf: allow specifying map definitions using BTF

2019-06-06 Thread Daniel Borkmann
On 06/04/2019 07:31 PM, Andrii Nakryiko wrote: > On Tue, Jun 4, 2019 at 6:45 AM Stanislav Fomichev wrote: >> On 06/03, Stanislav Fomichev wrote: BTF is mandatory for _any_ new feature. >>> If something is easy to support without asking everyone to upgrade to >>> a bleeding edge llvm, why not

Re: [PATCH bpf v2 0/4] Fix unconnected bpf cgroup hooks

2019-06-06 Thread Daniel Borkmann
On 06/06/2019 10:51 PM, Andrey Ignatov wrote: > Andrey Ignatov [Thu, 2019-06-06 13:45 -0700]: >> Daniel Borkmann [Thu, 2019-06-06 07:36 -0700]: >>> Please refer to the patch 1/4 as the main patch with the details >>> on the current sendmsg hook API limitations and prop

[PATCH bpf v3 0/6] Fix unconnected bpf cgroup hooks

2019-06-06 Thread Daniel Borkmann
Add attach types to test_section_names.c and libbpf (Andrey) - Added given Acks, rest as-is v1 -> v2: - Split off uapi header sync and bpftool bits (Martin, Alexei) - Added missing bpftool doc and bash completion as well Daniel Borkmann (6): bpf: fix unconnected udp hooks bpf: sync toolin

[PATCH bpf v3 1/6] bpf: fix unconnected udp hooks

2019-06-06 Thread Daniel Borkmann
ressed in future through a different bpf_attach_type such that this case can be distinguished from the regular recvmsg paths, for example. Fixes: 1cedee13d25a ("bpf: Hooks for sys_sendmsg") Signed-off-by: Daniel Borkmann Acked-by: Andrey Ignatov Acked-by: Martin KaFai Lau Acke

[PATCH bpf v3 6/6] bpf: expand section tests for test_section_names

2019-06-06 Thread Daniel Borkmann
bbpf: attachable section(type) names are: [...] Summary: 38 PASSED, 0 FAILED Signed-off-by: Daniel Borkmann --- tools/testing/selftests/bpf/test_section_names.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/bpf/test_section_names.c b/tools/testing/

[PATCH bpf v3 5/6] bpf: more msg_name rewrite tests to test_sock_addr

2019-06-06 Thread Daniel Borkmann
ok .. [PASS] Test case: recvmsg6: return code !ok .. [PASS] Test case: recvmsg4: rewrite IP & port (asm) .. [PASS] Test case: recvmsg6: rewrite IP & port (asm) .. [PASS] [...] Signed-off-by: Daniel Borkmann Acked-by: Andrey Ignatov Acked-by: Martin KaFai Lau --- tools/testing/se

[PATCH bpf v3 4/6] bpf, bpftool: enable recvmsg attach types

2019-06-06 Thread Daniel Borkmann
Trivial patch to bpftool in order to complete enabling attaching programs to BPF_CGROUP_UDP{4,6}_RECVMSG. Signed-off-by: Daniel Borkmann Acked-by: Andrey Ignatov Acked-by: Martin KaFai Lau --- tools/bpf/bpftool/Documentation/bpftool-cgroup.rst | 6 +- tools/bpf/bpftool/Documentation

[PATCH bpf v3 2/6] bpf: sync tooling uapi header

2019-06-06 Thread Daniel Borkmann
Sync BPF uapi header in order to pull in BPF_CGROUP_UDP{4,6}_RECVMSG attach types. This is done and preferred as an extra patch in order to ease sync of libbpf. Signed-off-by: Daniel Borkmann Acked-by: Andrey Ignatov Acked-by: Martin KaFai Lau --- tools/include/uapi/linux/bpf.h | 2 ++ 1 file

[PATCH bpf v3 3/6] bpf, libbpf: enable recvmsg attach types

2019-06-06 Thread Daniel Borkmann
Another trivial patch to libbpf in order to enable identifying and attaching programs to BPF_CGROUP_UDP{4,6}_RECVMSG by section name. Signed-off-by: Daniel Borkmann --- tools/lib/bpf/libbpf.c | 4 1 file changed, 4 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c

pull-request: bpf 2019-06-07

2019-06-07 Thread Daniel Borkmann
32-bits for and/or/xor on ALU32 selftests: bpf: add zero extend checks for ALU32 and/or/xor Chang-Hsien Tsai (1): samples, bpf: fix to change the buffer size for read() Daniel Borkmann (7): Merge branch 'bpf-subreg-tests' bpf: fix unconnected udp hooks bpf:

Re: [PATCH v4 bpf-next 0/2] bpf: Add a new API libbpf_num_possible_cpus()

2019-06-07 Thread Daniel Borkmann
On 06/07/2019 06:37 PM, Hechao Li wrote: > Getting number of possible CPUs is commonly used for per-CPU BPF maps > and perf_event_maps. Add a new API libbpf_num_possible_cpus() that > helps user with per-CPU related operations and remove duplicate > implementations in bpftool and selftests. > > v4

Re: [PATCH v4 bpf-next 0/2] bpf: Add a new API

2019-06-07 Thread Daniel Borkmann
On 06/08/2019 01:25 AM, Roman Gushchin wrote: > On 06/07/2019 06:37 PM, Hechao Li wrote: >> Getting number of possible CPUs is commonly used for per-CPU BPF maps >> and perf_event_maps. Add a new API libbpf_num_possible_cpus() that >> helps user with per-CPU related operations and remove duplicate

Re: [PATCH v2 bpf-next] selftests/bpf: fix "alu with different scalars 1" on s390

2019-07-15 Thread Daniel Borkmann
On 7/16/19 12:13 AM, Alexei Starovoitov wrote: > On Thu, Jul 4, 2019 at 1:53 AM Ilya Leoshkevich wrote: >> >> BPF_LDX_MEM is used to load the least significant byte of the retrieved >> test_val.index, however, on big-endian machines it ends up retrieving >> the most significant byte. >> >> Use the

Re: [PATCH v3 bpf 0/3] fix BTF verification size resolution

2019-07-15 Thread Daniel Borkmann
On 7/12/19 7:25 PM, Andrii Nakryiko wrote: > BTF size resolution logic isn't always resolving type size correctly, leading > to erroneous map creation failures due to value size mismatch. > > This patch set: > 1. fixes the issue (patch #1); > 2. adds tests for trickier cases (patch #2); > 3. and c

Re: [PATCH bpf] selftests/bpf: fix attach_probe on s390

2019-07-15 Thread Daniel Borkmann
On 7/12/19 3:41 PM, Ilya Leoshkevich wrote: > attach_probe test fails, because it cannot install a kprobe on a > non-existent sys_nanosleep symbol. > > Use the correct symbol name for the nanosleep syscall on 64-bit s390. > Don't bother adding one for 31-bit mode, since tests are compiled only > i

Re: [PATCH bpf] selftests/bpf: make directory prerequisites order-only

2019-07-15 Thread Daniel Borkmann
On 7/12/19 3:56 PM, Ilya Leoshkevich wrote: > When directories are used as prerequisites in Makefiles, they can cause > a lot of unnecessary rebuilds, because a directory is considered changed > whenever a file in this directory is added, removed or modified. > > If the only thing a target is inte

Re: [PATCH bpf 0/5] bpf: allow wide (u64) aligned loads for some fields of bpf_sock_addr

2019-07-15 Thread Daniel Borkmann
On 7/15/19 6:39 PM, Stanislav Fomichev wrote: > When fixing selftests by adding support for wide stores, Yonghong > reported that he had seen some examples where clang generates > single u64 loads for two adjacent u32s as well: > http://lore.kernel.org/netdev/a66c937f-94c0-eaf8-5b37-8587d66c0...@fb

Re: [PATCH bpf] samples/bpf: build with -D__TARGET_ARCH_$(SRCARCH)

2019-07-15 Thread Daniel Borkmann
On 7/15/19 11:11 AM, Ilya Leoshkevich wrote: > While $ARCH can be relatively flexible (see Makefile and > tools/scripts/Makefile.arch), $SRCARCH always corresponds to a directory > name under arch/. > > Therefore, build samples with -D__TARGET_ARCH_$(SRCARCH), since that > matches the expectations

Re: [PATCH bpf] selftests/bpf: put test_stub.o into $(OUTPUT)

2019-07-15 Thread Daniel Borkmann
On 7/12/19 3:59 PM, Ilya Leoshkevich wrote: > Add a rule to put test_stub.o in $(OUTPUT) and change the references to > it accordingly. This prevents test_stub.o from being created in the > source directory. > > Signed-off-by: Ilya Leoshkevich Applied, thanks!

Re: [PATCH v2 bpf-next] selftests/bpf: remove logic duplication in test_verifier.c

2019-07-15 Thread Daniel Borkmann
On 7/12/19 7:44 PM, Andrii Nakryiko wrote: > test_verifier tests can specify single- and multi-runs tests. Internally > logic of handling them is duplicated. Get rid of it by making single run > retval/data specification to be a first run spec. > > Cc: Krzesimir Nowak > Signed-off-by: Andrii Nakr

Re: [PATCH bpf v4 00/14] sockmap/tls fixes

2019-07-22 Thread Daniel Borkmann
On 7/19/19 7:37 PM, Jakub Kicinski wrote: > On Fri, 19 Jul 2019 10:29:13 -0700, Jakub Kicinski wrote: >> John says: >> >> Resolve a series of splats discovered by syzbot and an unhash >> TLS issue noted by Eric Dumazet. > > Sorry for the delay, this code is quite tricky. According to my testing >

Re: [GIT PULL 0/2] libbpf build fixes

2019-07-22 Thread Daniel Borkmann
On 7/19/19 4:34 PM, Arnaldo Carvalho de Melo wrote: > Hi Daniel, > > Please consider pulling or applying from the patches, if someone > has any issues, please holler, > > - Arnaldo > > Arnaldo Carvalho de Melo (2): > libbpf: Fix endianness macro usage for some compilers > libbpf: Avoid

Re: [PATCH bpf] selftests/bpf: fix sendmsg6_prog on s390

2019-07-22 Thread Daniel Borkmann
On 7/19/19 11:06 AM, Ilya Leoshkevich wrote: > "sendmsg6: rewrite IP & port (C)" fails on s390, because the code in > sendmsg_v6_prog() assumes that (ctx->user_ip6[0] & 0x) refers to > leading IPv6 address digits, which is not the case on big-endian > machines. > > Since checking bitwise opera

bpf-next is OPEN

2019-07-22 Thread Daniel Borkmann
Merge window is closed, therefore new round begins. Thanks everyone, Daniel

[PATCH net 1/2] sock: make cookie generation global instead of per netns

2019-08-08 Thread Daniel Borkmann
generated hence knowledge of the counter value does not provide much value either way. Signed-off-by: Daniel Borkmann Cc: Eric Dumazet Cc: Alexei Starovoitov Cc: Willem de Bruijn Cc: Martynas Pumputis --- include/net/net_namespace.h | 1 - include/uapi/linux/bpf.h| 4 ++-- net/core

[PATCH net 2/2] bpf: sync bpf.h to tools infrastructure

2019-08-08 Thread Daniel Borkmann
Pull in updates in BPF helper function description. Signed-off-by: Daniel Borkmann --- tools/include/uapi/linux/bpf.h | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 4e455018da65..a5aa7d3ac6a1

[PATCH net 0/2] Fix collisions in socket cookie generation

2019-08-08 Thread Daniel Borkmann
gh it cleanly applies to net-next as well). Went for net tree instead of bpf tree here given the main change is in net/core/sock_diag.c, but either way would be fine with me. Thanks a lot! Daniel Borkmann (2): sock: make cookie generation global instead of per netns bpf: sync bpf.h to

Re: [PATCH net 1/2] sock: make cookie generation global instead of per netns

2019-08-08 Thread Daniel Borkmann
On 8/8/19 12:45 PM, Eric Dumazet wrote: On Thu, Aug 8, 2019 at 11:50 AM Daniel Borkmann wrote: Socket cookie consumers must assume the value as opqaue in any case. The cookie does not guarantee an always unique identifier since it could wrap in fabricated corner cases where two sockets could

Re: [PATCH net 1/2] sock: make cookie generation global instead of per netns

2019-08-08 Thread Daniel Borkmann
On 8/8/19 1:37 PM, Eric Dumazet wrote: On Thu, Aug 8, 2019 at 1:09 PM Daniel Borkmann wrote: On 8/8/19 12:45 PM, Eric Dumazet wrote: On Thu, Aug 8, 2019 at 11:50 AM Daniel Borkmann wrote: Socket cookie consumers must assume the value as opqaue in any case. The cookie does not guarantee an

[PATCH net v2 1/2] sock: make cookie generation global instead of per netns

2019-08-08 Thread Daniel Borkmann
. Socket cookie consumers must assume the value as opqaue in any case. Not every socket must have a cookie generated and knowledge of the counter value itself does not provide much value either way hence conversion to global is fine. Signed-off-by: Daniel Borkmann Cc: Eric Dumazet Cc: Alexei

[PATCH net v2 0/2] Fix collisions in socket cookie generation

2019-08-08 Thread Daniel Borkmann
gh it cleanly applies to net-next as well). Went for net tree instead of bpf tree here given the main change is in net/core/sock_diag.c, but either way would be fine with me. Thanks a lot! v1 -> v2: - Fix up commit description in patch #1, thanks Eric! Daniel Borkmann (2): sock: mak

[PATCH net v2 2/2] bpf: sync bpf.h to tools infrastructure

2019-08-08 Thread Daniel Borkmann
Pull in updates in BPF helper function description. Signed-off-by: Daniel Borkmann --- tools/include/uapi/linux/bpf.h | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 4e455018da65..a5aa7d3ac6a1

Re: [PATCH bpf 0/2] tools: bpftool: fix pinning error messages

2019-08-09 Thread Daniel Borkmann
On 8/7/19 2:19 AM, Jakub Kicinski wrote: Hi! First make sure we don't use "prog" in error messages because the pinning operation could be performed on a map. Second add back missing error message if pin syscall failed. Jakub Kicinski (2): tools: bpftool: fix error message (prog -> object)

Re: [bpf-next v3 PATCH 0/3] bpf: improvements to xdp_fwd sample

2019-08-09 Thread Daniel Borkmann
On 8/8/19 6:17 PM, Jesper Dangaard Brouer wrote: V3: Hopefully fixed all issues point out by Yonghong Song V2: Addressed issues point out by Yonghong Song - Please ACK patch 2/3 again - Added ACKs and reviewed-by to other patches This patchset is focused on improvements for XDP forwarding s

pull-request: bpf 2019-08-11

2019-08-11 Thread Daniel Borkmann
for jmp to 1st insn selftests/bpf: tests for jmp to 1st insn Andrii Nakryiko (2): libbpf: fix erroneous multi-closing of BTF FD libbpf: set BTF FD for prog only when there is supported .BTF.ext data Daniel Borkmann (1): Merge branch 'bpf-bpftool-pinning-error-msg' Jakub Kici

Re: [PATCH v3] tools: bpftool: fix reading from /proc/config.gz

2019-08-12 Thread Daniel Borkmann
On 8/9/19 2:39 AM, Peter Wu wrote: /proc/config has never existed as far as I can see, but /proc/config.gz is present on Arch Linux. Add support for decompressing config.gz using zlib which is a mandatory dependency of libelf. Replace existing stdio functions with gzFile operations since the latt

Re: [PATCH bpf-next v2 2/4] bpf: support cloning sk storage on accept()

2019-08-12 Thread Daniel Borkmann
On 8/9/19 6:10 PM, Stanislav Fomichev wrote: Add new helper bpf_sk_storage_clone which optionally clones sk storage and call it from sk_clone_lock. Cc: Martin KaFai Lau Cc: Yonghong Song Signed-off-by: Stanislav Fomichev [...] +int bpf_sk_storage_clone(const struct sock *sk, struct sock *ne

Re: [PATCH bpf-next v4 1/2] xsk: remove AF_XDP socket from map when the socket is released

2019-08-12 Thread Daniel Borkmann
On 8/2/19 10:11 AM, Björn Töpel wrote: From: Björn Töpel When an AF_XDP socket is released/closed the XSKMAP still holds a reference to the socket in a "released" state. The socket will still use the netdev queue resource, and block newly created sockets from attaching to that queue, but no use

Re: [PATCH bpf] s390/bpf: fix lcgr instruction encoding

2019-08-12 Thread Daniel Borkmann
On 8/12/19 5:03 PM, Ilya Leoshkevich wrote: "masking, test in bounds 3" fails on s390, because BPF_ALU64_IMM(BPF_NEG, BPF_REG_2, 0) ignores the top 32 bits of BPF_REG_2. The reason is that JIT emits lcgfr instead of lcgr. The associated comment indicates that the code was intended to emit lcgr in

Re: [RESEND][PATCH v3 bpf-next] btf: expose BTF info through sysfs

2019-08-13 Thread Daniel Borkmann
On 8/12/19 8:39 PM, Andrii Nakryiko wrote: Make .BTF section allocated and expose its contents through sysfs. /sys/kernel/btf directory is created to contain all the BTFs present inside kernel. Currently there is only kernel's main BTF, represented as /sys/kernel/btf/kernel file. Once kernel mod

Re: [PATCH] tools: bpftool: add feature check for zlib

2019-08-13 Thread Daniel Borkmann
On 8/13/19 2:38 AM, Peter Wu wrote: bpftool requires libelf, and zlib for decompressing /proc/config.gz. zlib is a transitive dependency via libelf, and became mandatory since elfutils 0.165 (Jan 2016). The feature check of libelf is already done in the elfdep target of tools/lib/bpf/Makefile, pu

Re: [bpf-next] selftests/bpf: fix race in flow dissector tests

2019-08-13 Thread Daniel Borkmann
On 8/13/19 1:30 AM, Petar Penkov wrote: From: Petar Penkov Since the "last_dissection" map holds only the flow keys for the most recent packet, there is a small race in the skb-less flow dissector tests if a new packet comes between transmitting the test packet, and reading its keys from the ma

Re: [PATCH bpf-next v2 2/4] bpf: support cloning sk storage on accept()

2019-08-13 Thread Daniel Borkmann
On 8/12/19 7:52 PM, Stanislav Fomichev wrote: On 08/12, Daniel Borkmann wrote: On 8/9/19 6:10 PM, Stanislav Fomichev wrote: Add new helper bpf_sk_storage_clone which optionally clones sk storage and call it from sk_clone_lock. Cc: Martin KaFai Lau Cc: Yonghong Song Signed-off-by: Stanislav

Re: [PATCH bpf-next 0/2] libbpf: make use of BTF through sysfs

2019-08-13 Thread Daniel Borkmann
On 8/13/19 8:54 PM, Andrii Nakryiko wrote: Now that kernel's BTF is exposed through sysfs at well-known location, attempt to load it first as a target BTF for the purpose of BPF CO-RE relocations. Patch #1 is a follow-up patch to rename /sys/kernel/btf/kernel into /sys/kernel/btf/vmlinux. Patch

Re: [PATCH bpf 1/2] bpf: support PTR_TO_MEM{,_OR_NULL} register spilling

2021-01-12 Thread Daniel Borkmann
On 1/12/21 8:46 PM, Andrii Nakryiko wrote: On Tue, Jan 12, 2021 at 1:14 AM Gilad Reti wrote: Add support for pointer to mem register spilling, to allow the verifier to track pointer to valid memory addresses. Such pointers are returned for example by a successful call of the bpf_ringbuf_reserv

Re: [PATCH bpf 2/2] libbpf: allow loading empty BTFs

2021-01-12 Thread Daniel Borkmann
On 1/12/21 7:41 AM, Andrii Nakryiko wrote: On Mon, Jan 11, 2021 at 5:16 PM Yonghong Song wrote: On 1/11/21 12:51 PM, Andrii Nakryiko wrote: On Mon, Jan 11, 2021 at 10:13 AM Yonghong Song wrote: On 1/9/21 11:03 PM, Andrii Nakryiko wrote: Empty BTFs do come up (e.g., simple kernel modules wit

Re: [PATCH v3 bpf-next 5/7] bpf: support BPF ksym variables in kernel modules

2021-01-13 Thread Daniel Borkmann
On 1/13/21 12:18 AM, Alexei Starovoitov wrote: On Tue, Jan 12, 2021 at 8:30 AM Daniel Borkmann wrote: On 1/12/21 8:55 AM, Andrii Nakryiko wrote: Add support for directly accessing kernel module variables from BPF programs using special ldimm64 instructions. This functionality builds upon

  1   2   3   4   5   6   7   8   9   10   >