Re: [PATCH bpf] libbpf: handle BTF parsing and loading properly

2019-03-11 Thread Daniel Borkmann
On 03/09/2019 12:58 AM, Andrii Nakryiko wrote: > This patch splits and cleans up error handling logic for loading BTF data. > Previously, if BTF data was parsed successfully, but failed to load into > kernel, we'd report nonsensical error code, instead of error returned from > btf__load(). Now btf_

[PATCH rfc v3 bpf-next 3/9] bpf: add syscall side map lock support

2019-03-11 Thread Daniel Borkmann
_LOCK upon need. Signed-off-by: Daniel Borkmann --- include/linux/bpf.h | 5 ++- include/uapi/linux/bpf.h | 1 + kernel/bpf/syscall.c | 72 +--- 3 files changed, 65 insertions(+), 13 deletions(-) diff --git a/include/linux/bpf.h b/include/li

[PATCH rfc v3 bpf-next 9/9] bpf, selftest: test global data/bss/rodata sections

2019-03-11 Thread Daniel Borkmann
passing in const data. Joint work with Daniel Borkmann. Signed-off-by: Joe Stringer Signed-off-by: Daniel Borkmann --- tools/testing/selftests/bpf/bpf_helpers.h | 8 +- .../selftests/bpf/prog_tests/global_data.c| 157 ++ .../selftests/bpf/progs/test_global_data.c

[PATCH rfc v3 bpf-next 4/9] bpf, obj: allow . char as part of the name

2019-03-11 Thread Daniel Borkmann
Trivial addition to allow '.' aside from '_' as "special" characters in the object name. Used to allow for substrings in maps from loader side such as ".bss", ".data", ".rodata", but could also be useful for other purposes. Signed-off-

[PATCH rfc v3 bpf-next 8/9] bpf, selftest: test {rd,wr}only flags and direct value access

2019-03-11 Thread Daniel Borkmann
27;, bad access 1 OK #921/p XDP pkt read, pkt_data <= pkt_meta', bad access 2 OK Summary: 1366 PASSED, 1 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann --- tools/include/linux/filter.h | 14 ++ tools/testing/selftests/bpf/test_verifier.c | 42 +++- .../selfte

[PATCH rfc v3 bpf-next 5/9] bpf: sync bpf.h uapi header from tools infrastructure

2019-03-11 Thread Daniel Borkmann
Pull in latest changes, so we can make use of them in libbpf. Signed-off-by: Daniel Borkmann --- tools/include/uapi/linux/bpf.h | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index

[PATCH rfc v3 bpf-next 0/9] BPF support for global data

2019-03-11 Thread Daniel Borkmann
y for these maps (Alexei) -> Waiting till BTF support for these lands first v1 -> v2: - Instead of 32-bit static data, implement full global data support (Alexei) [0] https://patchwork.ozlabs.org/cover/1040290/ [1] http://vger.kernel.org/lpc-bpf2018.html#session-3 Dani

[PATCH rfc v3 bpf-next 6/9] bpf, libbpf: refactor relocation handling

2019-03-11 Thread Daniel Borkmann
From: Joe Stringer Adjust the code for relocations slightly with no functional changes, so that upcoming patches that will introduce support for relocations into the .data, .rodata and .bss sections can be added independent of these changes. Signed-off-by: Joe Stringer Signed-off-by: Daniel

[PATCH rfc v3 bpf-next 1/9] bpf: implement lookup-free direct value access for maps

2019-03-11 Thread Daniel Borkmann
required. Loader support has been added in subsequent commits for libbpf library. Signed-off-by: Daniel Borkmann --- include/linux/bpf.h | 6 ++ include/linux/bpf_verifier.h | 4 ++ include/uapi/linux/bpf.h | 13 +++- kernel/bpf/arraymap.c | 29

[PATCH rfc v3 bpf-next 7/9] bpf, libbpf: support global data/bss/rodata sections

2019-03-11 Thread Daniel Borkmann
str2[2], "hello", sizeof("hello")); 142: (73) *(u8 *)(r8 +6) = r1 <-- further access based on .bss data 143: (b7) r1 = 108 144: (73) *(u8 *)(r8 +5) = r1 [...] Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables"

[PATCH rfc v3 bpf-next 2/9] bpf: add program side {rd,wr}only support for maps

2019-03-11 Thread Daniel Borkmann
e and stack. Further map types could be followed up in future depending on use-case. Main use case here is to forbid writes into .rodata map values from verifier side. Signed-off-by: Daniel Borkmann --- include/linux/bpf.h | 24 ++ include/uapi/linux/bpf.h

Re: [PATCH rfc v3 bpf-next 2/9] bpf: add program side {rd,wr}only support for maps

2019-03-11 Thread Daniel Borkmann
On 03/12/2019 12:06 AM, Alexei Starovoitov wrote: > On Mon, Mar 11, 2019 at 10:51:18PM +0100, Daniel Borkmann wrote: >> This work adds two new map creation flags BPF_F_RDONLY_PROG >> and BPF_F_WRONLY_PROG in order to allow for read-only or >> write-only BPF maps fr

Re: [PATCH bpf v2] libbpf: fix to reject unknown flags in xsk_socket__create()

2019-03-12 Thread Daniel Borkmann
On 03/12/2019 09:02 PM, Andrii Nakryiko wrote: > On Tue, Mar 12, 2019 at 12:44 PM Magnus Karlsson > wrote: >> >> On Tue, Mar 12, 2019 at 8:27 PM Andrii Nakryiko >> wrote: >>> >>> On Tue, Mar 12, 2019 at 2:00 AM Magnus Karlsson >>> wrote: In xsk_socket__create(), the libbpf_flags field

Re: [PATCH bpf] selftests/bpf: fix segfault of test_progs when prog loading failed

2019-03-12 Thread Daniel Borkmann
st_progs > ... > Summary: 219 PASSED, 2 FAILED > > Fixes: b4d4556c3266 ("selftests/bpf: add bpf_spin_lock verifier tests") > Fixes: ba72a7b4badb ("selftests/bpf: test for BPF_F_LOCK") > Reported-by: Daniel Borkmann > Signed-off-by: Yonghong Song Applied, thanks!

Re: [PATCH bpf v2] libbpf: fix to reject unknown flags in xsk_socket__create()

2019-03-12 Thread Daniel Borkmann
On 03/12/2019 09:52 PM, Daniel Borkmann wrote: > On 03/12/2019 09:02 PM, Andrii Nakryiko wrote: >> On Tue, Mar 12, 2019 at 12:44 PM Magnus Karlsson >> wrote: >>> >>> On Tue, Mar 12, 2019 at 8:27 PM Andrii Nakryiko >>> wrote: >>>> >>&g

Re: [PATCH bpf] xsk: fix umem memory leak on cleanup

2019-03-15 Thread Daniel Borkmann
On 03/13/2019 03:15 PM, Björn Töpel wrote: > From: Björn Töpel > > When the umem is cleaned up, the task that created it might already be > gone. If the task was gone, the xdp_umem_release function did not free > the pages member of struct xdp_umem. > > It turned out that the task lookup was not

pull-request: bpf 2019-03-16

2019-03-15 Thread Daniel Borkmann
Hi David, The following pull-request contains BPF updates for your *net* tree. The main changes are: 1) Fix a umem memory leak on cleanup in AF_XDP, from Björn. 2) Fix BTF to properly resolve forward-declared enums into their corresponding full enum definition types during deduplication, fro

Re: [PATCH v3 bpf] bpf: Try harder when allocating memory for large maps

2019-03-18 Thread Daniel Borkmann
On 03/18/2019 04:39 PM, Michal Hocko wrote: > On Mon 18-03-19 16:10:26, Martynas Pumputis wrote: >> It has been observed that sometimes a higher order memory allocation >> for BPF maps fails when there is no obvious memory pressure in a system. >> >> E.g. the map (BPF_MAP_TYPE_LRU_HASH, key=38, val

bpf-next is OPEN

2019-03-19 Thread Daniel Borkmann
Merge window is closed, so new round begins. Thanks everyone, Daniel

Re: bpf-next is OPEN

2019-03-19 Thread Daniel Borkmann
On 03/19/2019 06:01 PM, Alban Crequy wrote: > On Tue, 19 Mar 2019 at 09:56, Daniel Borkmann wrote: >> >> Merge window is closed, so new round begins. >> >> Thanks everyone, >> Daniel > > Thanks! I see that the bpf tree is more recent than the bpf-next tree

Re: [PATCH bpf-next v2] tools/bpf: generate pkg-config file for libbpf

2019-03-20 Thread Daniel Borkmann
On 03/20/2019 09:44 PM, Stanislav Fomichev wrote: > On 03/20, Luca Boccassi wrote: >> On Wed, 2019-03-20 at 10:21 -0700, Stanislav Fomichev wrote: >>> On 03/20, Luca Boccassi wrote: On Wed, 2019-03-20 at 13:22 +, Luca Boccassi wrote: > On Tue, 2019-03-19 at 16:17 -0700, Stanislav Fomic

Re: [PATCHv2 bpf-next 1/3] bpf, tests: tweak endianness selection

2019-03-20 Thread Daniel Borkmann
On 03/20/2019 11:45 PM, Yonghong Song wrote: > On 3/20/19 3:27 PM, Stanislav Fomichev wrote: >> On 03/20, Yonghong Song wrote: >>> On 3/20/19 10:13 AM, Stanislav Fomichev wrote: On 03/20, Sergey Senozhatsky wrote: > Not all compilers have __builtin_bswap16() and __builtin_bswap32(), >

Re: [PATCH bpf-next v4] tools/bpf: generate pkg-config file for libbpf

2019-03-21 Thread Daniel Borkmann
On 03/21/2019 11:01 PM, Alexei Starovoitov wrote: > On Thu, Mar 21, 2019 at 04:00:46PM +, Andrey Ignatov wrote: >> luca.bocca...@gmail.com [Thu, 2019-03-21 03:26 >> -0700]: >>> From: Luca Boccassi >>> >>> Generate a libbpf.pc file at build time so that users can rely >>> on pkg-config to fin

[PATCH bpf 0/2] libbpf fix up and clarify version info

2019-03-22 Thread Daniel Borkmann
First one is fixing version in Makefile and shared object and second one clarifies bump in version. Thanks! Daniel Borkmann (2): bpf, libbpf: fix version info and add it to shared object bpf, libbpf: clarify bump in libbpf version info tools/lib/bpf/Makefile | 42

[PATCH bpf 1/2] bpf, libbpf: fix version info and add it to shared object

2019-03-22 Thread Daniel Borkmann
pf feature check") Reported-by: Stanislav Fomichev Signed-off-by: Daniel Borkmann --- tools/lib/bpf/Makefile | 42 -- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 61aaacf..ada2

[PATCH bpf 2/2] bpf, libbpf: clarify bump in libbpf version info

2019-03-22 Thread Daniel Borkmann
eported-by: Stanislav Fomichev Signed-off-by: Daniel Borkmann --- tools/lib/bpf/README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/README.rst b/tools/lib/bpf/README.rst index 5788479..cef7b77 100644 --- a/tools/lib/bpf/README.rst +++ b/tools/lib/bpf/README.rst @@ -11

Re: [PATCH bpf 1/2] bpf, libbpf: fix version info and add it to shared object

2019-03-22 Thread Daniel Borkmann
On 03/23/2019 01:28 AM, Stanislav Fomichev wrote: > On 03/23, Daniel Borkmann wrote: >> On 03/23/2019 01:09 AM, Stanislav Fomichev wrote: >>> On 03/23, Daniel Borkmann wrote: >> [...] >>>> +$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN) >>>> + $

[PATCH bpf v2 0/2] libbpf fix up and clarify version info

2019-03-22 Thread Daniel Borkmann
First one is fixing version in Makefile and shared object and second one clarifies bump in version. Thanks! v1 -> v2: - Fix up soname, thanks Stanislav! Daniel Borkmann (2): bpf, libbpf: fix version info and add it to shared object bpf, libbpf: clarify bump in libbpf version info to

[PATCH bpf v2 1/2] bpf, libbpf: fix version info and add it to shared object

2019-03-22 Thread Daniel Borkmann
program types") Fixes: 1b76c13e4b36 ("bpf tools: Introduce 'bpf' library and add bpf feature check") Reported-by: Stanislav Fomichev Signed-off-by: Daniel Borkmann --- tools/lib/bpf/Makefile | 42 -- 1 file changed, 28 insertions(

[PATCH bpf v2 2/2] bpf, libbpf: clarify bump in libbpf version info

2019-03-22 Thread Daniel Borkmann
eported-by: Stanislav Fomichev Signed-off-by: Daniel Borkmann --- tools/lib/bpf/README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/README.rst b/tools/lib/bpf/README.rst index 5788479..cef7b77 100644 --- a/tools/lib/bpf/README.rst +++ b/tools/lib/bpf/README.rst @@ -11

Re: [PATCH bpf-next v3 00/13] bpf tc tunneling

2019-03-23 Thread Daniel Borkmann
Hey Willem, On 03/22/2019 07:32 PM, Willem de Bruijn wrote: > From: Willem de Bruijn > > BPF allows for dynamic tunneling, choosing the tunnel destination and > features on-demand. Extend bpf_skb_adjust_room to allow for efficient > tunneling at the TC hooks. Patch 9 in this series caused the f

Re: [PATCH bpf-next 00/21] bpf: Sysctl hook

2019-03-25 Thread Daniel Borkmann
Hi Andrey, On 03/24/2019 01:12 AM, Andrey Ignatov wrote: > The patch set introduces new BPF hook for sysctl. > > It adds new program type BPF_PROG_TYPE_CGROUP_SYSCTL and attach type > BPF_CGROUP_SYSCTL. > > BPF_CGROUP_SYSCTL hook is placed before calling to sysctl's proc_handler so > that access

Re: [PATCH 2/2] samples/bpf: add NULL check for ksym_search

2019-03-25 Thread Daniel Borkmann
On 03/15/2019 07:42 AM, Daniel T. Lee wrote: > Since, ksym_search added with verification logic for symbols existence, > it could return NULL when the kernel symbols are not loaded. > > This commit will add NULL check logic after ksym_search. > > Signed-off-by: Daniel T. Lee > --- > samples/bpf

Re: [PATCH bpf-next] selftests: bpf: don't depend on hardcoded perf sample_freq

2019-03-25 Thread Daniel Borkmann
On 03/19/2019 10:53 PM, Stanislav Fomichev wrote: > When running stacktrace_build_id_nmi, try to query > kernel.perf_event_max_sample_rate sysctl and use it as a sample_freq. > If there was an error reading sysctl, fallback to 5000. > > kernel.perf_event_max_sample_rate sysctl can drift and/or can

Re: [PATCH bpf-next] bpf: test_tc_tunnel.sh needs reverse path filtering disabled

2019-03-25 Thread Daniel Borkmann
On 03/25/2019 10:36 AM, Alan Maguire wrote: > test_tc_tunnel.sh sets up a pair of namespaces connected by a > veth pair to verify encap/decap using bpf_skb_adjust_room. In > testing this, it uses tunnel links as the peer of the bpf-based > encap/decap. However because the same IP header is used f

Re: [PATCH v4 bpf-next 1/3] bpf: add bpf_progenyof helper

2019-03-25 Thread Daniel Borkmann
On 03/22/2019 11:38 PM, Javier Honduvilla Coto wrote: > This patch adds the bpf_progenyof helper which receives a PID and returns > 1 if the process currently being executed is in the process hierarchy > including itself or 0 if not. > > This is very useful in tracing programs when we want to filt

Re: [PATCH bpf v3 0/2] bpf: mark registers in all frames after pkt/null checks

2019-04-25 Thread Daniel Borkmann
On 04/25/2019 10:46 PM, Alexei Starovoitov wrote: > On Wed, Apr 24, 2019 at 09:49:58PM +0200, Paul Chaignon wrote: >> In case of a null check on a pointer inside a subprog, we should mark all >> registers with this pointer as either safe or unknown, in both the current >> and previous frames. Curr

Re: [PATCH bpf-next v4 1/2] bpf: support BPF_PROG_QUERY for BPF_FLOW_DISSECTOR attach_type

2019-04-25 Thread Daniel Borkmann
On 04/24/2019 11:31 PM, Stanislav Fomichev wrote: > target_fd is target namespace. If there is a flow dissector BPF program > attached to that namespace, its (single) id is returned. > > v4: > * add missing put_net (Jann Horn) > > v3: > * add missing inline to skb_flow_dissector_prog_query static

Re: [PATCH] samples: bpf: add hbm sample to .gitignore

2019-04-25 Thread Daniel Borkmann
On 04/25/2019 11:02 AM, Daniel T. Lee wrote: > This commit adds hbm to .gitignore which is > currently ommited from the ignore file. > > Signed-off-by: Daniel T. Lee Applied, thanks.

Re: [PATCH] libbpf: fix samples/bpf build failure due to undefined UINT32_MAX

2019-04-25 Thread Daniel Borkmann
On 04/23/2019 10:24 PM, Daniel T. Lee wrote: > Currently, building bpf samples will cause the following error. > > ./tools/lib/bpf/bpf.h:132:27: error: 'UINT32_MAX' undeclared here (not in > a function) .. > #define BPF_LOG_BUF_SIZE (UINT32_MAX >> 8) /* verifier maximum in > kernels <=

Re: [PATCH bpf-next v5 1/2] bpf: support BPF_PROG_QUERY for BPF_FLOW_DISSECTOR attach_type

2019-04-25 Thread Daniel Borkmann
On 04/25/2019 11:37 PM, Stanislav Fomichev wrote: > target_fd is target namespace. If there is a flow dissector BPF program > attached to that namespace, its (single) id is returned. > > v5: > * drop net ref right after rcu unlock (Daniel Borkmann) > > v4: > * add mi

[PATCH bpf-next 2/2] bpf, arm64: use more scalable stadd over ldxr / stxr loop in xadd

2019-04-26 Thread Daniel Borkmann
encoder along with STADD as special case and use it in the JIT for CPUs that advertise LSE atomics in CPUID register. If immediate offset in the BPF XADD insn is 0, then use dst register directly instead of temporary one. Signed-off-by: Daniel Borkmann Acked-by: Jean-Philippe Brucker Acked-by: Will

[PATCH bpf-next 0/2] Two arm64 bpf jit improvements

2019-04-26 Thread Daniel Borkmann
This set holds two arm64 bpf jit improvements for xadd. Thanks! Daniel Borkmann (2): bpf, arm64: remove prefetch insn in xadd mapping bpf, arm64: use more scalable stadd over ldxr / stxr loop in xadd arch/arm64/include/asm/insn.h | 8 arch/arm64/kernel/insn.c | 40

[PATCH bpf-next 1/2] bpf, arm64: remove prefetch insn in xadd mapping

2019-04-26 Thread Daniel Borkmann
fetch instruction. Fixes: 85f68fe89832 ("bpf, arm64: implement jiting of BPF_XADD") Reported-by: Will Deacon Signed-off-by: Daniel Borkmann Acked-by: Jean-Philippe Brucker Acked-by: Will Deacon --- arch/arm64/net/bpf_jit.h | 6 -- arch/arm64/net/bpf_jit_comp.c | 1 - 2 files chang

Re: [PATCH iproute2-next] Update tc-bpf.8 man page examples

2019-04-26 Thread Daniel Borkmann
On 04/26/2019 07:40 PM, David Ahern wrote: > On 4/20/19 1:06 PM, Lucas Siba wrote: >> From: Lucas Siba @ 2019-04-20 11:40 UTC >> To: netdev >> >> This patch updates the tc-bpf.8 example application for changes to the >> struct bpf_elf_map definition. In it's current form, things compile, but >> the

pull-request: bpf-next 2019-04-28

2019-04-28 Thread Daniel Borkmann
bpftool: fix indendation in bash-completion/bpftool Benjamin Poirier (1): bpftool: Fix errno variable usage Daniel Borkmann (6): Merge branch 'bpf-eth-get-headlen' Merge branch 'bpf-proto-fixes' bpf, libbpf: handle old kernels more graceful wrt glob

Re: [net-next 01/12] i40e: replace switch-statement to speed-up retpoline-enabled builds

2019-05-02 Thread Daniel Borkmann
On 04/29/2019 09:16 PM, Jeff Kirsher wrote: > From: Björn Töpel > > GCC will generate jump tables for switch-statements with more than 5 > case statements. An entry into the jump table is an indirect call, > which means that for CONFIG_RETPOLINE builds, this is rather > expensive. > > This commi

Re: [PATCH bpf] kbuild: tolerate missing pahole when generating BTF

2019-05-06 Thread Daniel Borkmann
On 05/06/2019 02:10 AM, Andrii Nakryiko wrote: > When BTF generation is enabled through CONFIG_DEBUG_INFO_BTF, > scripts/link-vmlinux.sh detects if pahole version is too old and > gracefully continues build process, skipping BTF generation build step. > But if pahole is not available, build will st

Re: [PATCH bpf 1/2] libbpf: fix invalid munmap call

2019-05-06 Thread Daniel Borkmann
On 04/30/2019 02:45 PM, Björn Töpel wrote: > From: Björn Töpel > > When unmapping the AF_XDP memory regions used for the rings, an > invalid address was passed to the munmap() calls. Instead of passing > the beginning of the memory region, the descriptor region was passed > to munmap. > > When t

Re: [net-next 01/12] i40e: replace switch-statement to speed-up retpoline-enabled builds

2019-05-06 Thread Daniel Borkmann
On 04/30/2019 12:42 PM, David Laight wrote: > From: Josh Elsasser >> Sent: 29 April 2019 21:02 >> On Apr 29, 2019, at 12:16 PM, Jeff Kirsher >> wrote: >> >>> From: Björn Töpel >>> >>> GCC will generate jump tables for switch-statements with more than 5 >>> case statements. An entry into the jump

Re: [PATCH bpf 1/2] libbpf: fix invalid munmap call

2019-05-06 Thread Daniel Borkmann
On 05/06/2019 10:40 AM, Björn Töpel wrote: > On Mon, 6 May 2019 at 10:26, Daniel Borkmann wrote: >> On 04/30/2019 02:45 PM, Björn Töpel wrote: >>> From: Björn Töpel >>> >>> When unmapping the AF_XDP memory regions used for the rings, an >>> inv

Re: [bpf-next PATCH v3 0/4] sockmap/ktls fixes

2019-05-06 Thread Daniel Borkmann
On 05/02/2019 10:05 PM, John Fastabend wrote: > On 4/30/19 7:06 PM, John Fastabend wrote: >> Series of fixes for sockmap and ktls, see patches for descriptions. >> >> v2: fix build issue for CONFIG_TLS_DEVICE and fixup couple comments >> from Jakub >> >> v3: fix issue where release could call u

Re: selftests/bpf/test_tag takes ~30 minutes?

2019-05-06 Thread Daniel Borkmann
On 04/30/2019 03:21 PM, Michael Ellerman wrote: > Hi Daniel, > > I'm running selftests/bpf/test_tag and it's taking roughly half an hour > to complete, is that expected? > > I don't really grok what the test is doing TBH, but it does appear to be > doing it 5 times :) > > for (i = 0; i < 5

Re: [PATCH bpf] libbpf: remove unnecessary cast-to-void

2019-05-06 Thread Daniel Borkmann
On 05/06/2019 11:24 AM, Björn Töpel wrote: > From: Björn Töpel > > The patches with fixes tags added a cast-to-void in the places when > the return value of a function was ignored. > > This is not common practice in the kernel, and is therefore removed in > this patch. >

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

2019-05-06 Thread Daniel Borkmann
On 05/04/2019 06:06 PM, 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 que

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

2019-05-06 Thread Daniel Borkmann
On 05/06/2019 12:04 PM, Daniel Borkmann wrote: > On 05/04/2019 06:06 PM, 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

bpf-next is CLOSED

2019-05-06 Thread Daniel Borkmann
Only bug fixes from this point forward given the merge window is open. PRs will go out to David in a bit. Thanks everyone, Daniel

pull-request: bpf 2019-05-06

2019-05-06 Thread Daniel Borkmann
Hi David, The following pull-request contains BPF updates for your *net* tree. The main changes are: 1) Two x32 JIT fixes: one which has buggy signed comparisons in 64 bit conditional jumps and another one for 64 bit negation, both from Wang. Please consider pulling these changes from:

Re: [PATCH v6 bpf-next 02/17] bpf: verifier: mark verified-insn with sub-register zext flag

2019-05-06 Thread Daniel Borkmann
On 05/03/2019 12:42 PM, Jiong Wang wrote: > eBPF ISA specification requires high 32-bit cleared when low 32-bit > sub-register is written. This applies to destination register of ALU32 etc. > JIT back-ends must guarantee this semantic when doing code-gen. > > x86-64 and arm64 ISA has the same sema

Re: [PATCH v6 bpf-next 01/17] bpf: verifier: offer more accurate helper function arg and return type

2019-05-06 Thread Daniel Borkmann
On 05/03/2019 12:42 PM, Jiong Wang wrote: > BPF helper call transfers execution from eBPF insns to native functions > while verifier insn walker only walks eBPF insns. So, verifier can only > knows argument and return value types from explicit helper function > prototype descriptions. > > For 32-b

Re: [PATCH v6 bpf-next 02/17] bpf: verifier: mark verified-insn with sub-register zext flag

2019-05-06 Thread Daniel Borkmann
On 05/06/2019 03:49 PM, Daniel Borkmann wrote: > On 05/03/2019 12:42 PM, Jiong Wang wrote: >> eBPF ISA specification requires high 32-bit cleared when low 32-bit >> sub-register is written. This applies to destination register of ALU32 etc. >> JIT back-ends must guarantee thi

pull-request: bpf-next 2019-05-06

2019-05-06 Thread Daniel Borkmann
Hi David, The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) Two AF_XDP libbpf fixes for socket teardown; first one an invalid munmap and the other one an invalid skmap cleanup, both from Björn. 2) More graceful CONFIG_DEBUG_INFO_BTF handling w

Re: Question about seccomp / bpf

2019-05-09 Thread Daniel Borkmann
On 05/09/2019 12:58 PM, Eric Dumazet wrote: > On Thu, May 9, 2019 at 3:52 AM Eric Dumazet wrote: >> On Wed, May 8, 2019 at 9:47 PM Alexei Starovoitov >> wrote: >>> On Wed, May 08, 2019 at 04:17:29PM -0700, Eric Dumazet wrote: On Wed, May 8, 2019 at 4:09 PM Alexei Starovoitov wrote: >>>

[PATCH bpf 1/2] bpf: fix out of bounds backwards jmps due to dead code removal

2019-05-10 Thread Daniel Borkmann
ad code") Fixes: 2cbd95a5c4fb ("bpf: change parameters of call/branch offset adjustment") Reported-by: Frank Ch. Eigler Signed-off-by: Daniel Borkmann Reviewed-by: Jakub Kicinski --- kernel/bpf/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel

[PATCH bpf 2/2] bpf: add various test cases for backward jumps

2019-05-10 Thread Daniel Borkmann
Add a couple of tests to make sure branch offset adjustments are correctly performed. Signed-off-by: Daniel Borkmann --- tools/testing/selftests/bpf/verifier/jump.c | 151 1 file changed, 151 insertions(+) diff --git a/tools/testing/selftests/bpf/verifier/jump.c b/tools

Re: [PATCH v2] selftests: bpf: Add files generated after build to .gitignore

2019-05-12 Thread Daniel Borkmann
On 05/12/2019 09:29 AM, Kelsey Skunberg wrote: > The following files are generated after building /selftests/bpf/ and > should be added to .gitignore: > > - libbpf.pc > - libbpf.so.* > > Signed-off-by: Kelsey Skunberg Applied, thanks.

Re: [PATCH bpf 0/4] bpf: fix documentation for BPF helper functions

2019-05-12 Thread Daniel Borkmann
On 05/10/2019 04:51 PM, Quentin Monnet wrote: > Another round of fixes for the doc in the BPF UAPI header, which can be > turned into a manual page. First patch is the most important, as it fixes > parsing for the bpf_strtoul() helper doc. Following patches are formatting > fixes (nitpicks, mostly)

Re: [PATCH v3 bpf] libbpf: detect supported kernel BTF features and sanitize BTF

2019-05-12 Thread Daniel Borkmann
On 05/12/2019 03:09 AM, Stanislav Fomichev wrote: > On 05/11, Andrii Nakryiko wrote: >> On Fri, May 10, 2019 at 3:00 PM Stanislav Fomichev wrote: >>> On 05/10, Andrii Nakryiko wrote: On Fri, May 10, 2019 at 2:36 PM Stanislav Fomichev wrote: > On 05/10, Andrii Nakryiko wrote: >>

Re: [PATCH bpf v1] bpf: Fix undefined behavior in narrow load handling

2019-05-12 Thread Daniel Borkmann
On 05/10/2019 12:16 PM, Krzesimir Nowak wrote: > On Thu, May 9, 2019 at 11:30 PM Daniel Borkmann wrote: >> On 05/08/2019 06:08 PM, Krzesimir Nowak wrote: >>> Commit 31fd85816dbe ("bpf: permits narrower load from bpf program >>> context fields") made the verif

pull-request: bpf 2019-05-13

2019-05-12 Thread Daniel Borkmann
Nakryiko (1): libbpf: detect supported kernel BTF features and sanitize BTF Daniel Borkmann (3): bpf: fix out of bounds backwards jmps due to dead code removal bpf: add various test cases for backward jumps Merge branch 'bpf-uapi-doc-fixes' Kelsey S

[PATCH bpf 1/3] bpf: add map_lookup_elem_sys_only for lookups from syscall side

2019-05-13 Thread Daniel Borkmann
: Daniel Borkmann Acked-by: Martin KaFai Lau --- include/linux/bpf.h | 1 + kernel/bpf/syscall.c | 5 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 59631dd..4fb3aa2 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h

[PATCH bpf 0/3] BPF LRU map fix

2019-05-13 Thread Daniel Borkmann
This set fixes LRU map eviction in combination with map lookups out of system call side from user space. Main patch is the second one and test cases are adapted and added in the last one. Thanks! Daniel Borkmann (3): bpf: add map_lookup_elem_sys_only for lookups from syscall side bpf, lru

[PATCH bpf 3/3] bpf: test ref bit from data path and add new tests for syscall path

2019-05-13 Thread Daniel Borkmann
map_flags:0x2): Pass test_lru_sanity4 (map_type:10 map_flags:0x2): Pass test_lru_sanity6 (map_type:10 map_flags:0x2): Pass test_lru_sanity7 (map_type:10 map_flags:0x2): Pass test_lru_sanity8 (map_type:10 map_flags:0x2): Pass Signed-off-by: Daniel Borkmann Acked-by: Martin KaFai Lau --- tools

[PATCH bpf 2/3] bpf, lru: avoid messing with eviction heuristics upon syscall lookup

2019-05-13 Thread Daniel Borkmann
0] http://vger.kernel.org/bpfconf.html Fixes: 29ba732acbee ("bpf: Add BPF_MAP_TYPE_LRU_HASH") Fixes: 8f8449384ec3 ("bpf: Add BPF_MAP_TYPE_LRU_PERCPU_HASH") Signed-off-by: Daniel Borkmann Acked-by: Martin KaFai Lau --- kernel/bpf/hashtab.c | 23 ++- 1 file ch

Re: [PATCH net] bpf: devmap: fix use-after-free Read in __dev_map_entry_free

2019-05-13 Thread Daniel Borkmann
On 05/13/2019 06:59 PM, Eric Dumazet wrote: > synchronize_rcu() is fine when the rcu callbacks only need > to free memory (kfree_rcu() or direct kfree() call rcu call backs) > > __dev_map_entry_free() is a bit more complex, so we need to make > sure that call queued __dev_map_entry_free() callback

Re: [PATCH bpf] bpf: mark bpf_event_notify and bpf_event_init as static

2019-05-13 Thread Daniel Borkmann
On 05/13/2019 09:04 PM, Stanislav Fomichev wrote: > Both of them are not declared in the headers and not used outside > of bpf_trace.c file. > > Fixes: a38d1107f937c ("bpf: support raw tracepoints in modules") > Signed-off-by: Stanislav Fomichev Applied, thanks!

Re: [bpf PATCH 0/3] sockmap fixes

2019-05-13 Thread Daniel Borkmann
On 05/13/2019 04:19 PM, John Fastabend wrote: > A couple fixes for sockmap code. Previously this was bundled with a tls > fix for unhash() path however, that is becoming a larger fix so push > these on their own. Agree, applied, thanks!

Re: [PATCH bpf 1/3] bpf: add map_lookup_elem_sys_only for lookups from syscall side

2019-05-14 Thread Daniel Borkmann
On 05/14/2019 07:04 AM, Andrii Nakryiko wrote: > On Mon, May 13, 2019 at 4:20 PM Daniel Borkmann wrote: >> >> Add a callback map_lookup_elem_sys_only() that map implementations >> could use over map_lookup_elem() from system call side in case the >> map implementation

pull-request: bpf 2019-05-16

2019-05-15 Thread Daniel Borkmann
meo == 0 (2019-05-16 01:36:13 +0200) Alexei Starovoitov (1): Merge branch 'lru-map-fix' Daniel Borkmann (3): bpf: add map_lookup_elem_sys_only for lookups from syscall side bpf, lru: avoid messing with e

Re: [PATCH bpf 1/2] selftests/bpf: add missing \n to flow_dissector CHECK errors

2019-05-15 Thread Daniel Borkmann
On 05/14/2019 11:12 PM, Stanislav Fomichev wrote: > Otherwise, in case of an error, everything gets mushed together. > > Fixes: a5cb33464e53 ("selftests/bpf: make flow dissector tests more > extensible") > Signed-off-by: Stanislav Fomichev Both applied, thanks!

Re: [bpf PATCH] net: tcp_bpf, correctly handle DONT_WAIT flags and timeo == 0

2019-05-15 Thread Daniel Borkmann
On 05/14/2019 06:42 AM, John Fastabend wrote: > The tcp_bpf_wait_data() routine needs to check timeo != 0 before > calling sk_wait_event() otherwise we may see unexpected stalls > on receiver. > > Arika did all the leg work here I just formaatted, posted and ran > a few tests. > > Fixes: 604326b4

Re: [PATCH bpf] libbpf: don't fail when feature probing fails

2019-05-15 Thread Daniel Borkmann
On 05/15/2019 05:38 AM, Stanislav Fomichev wrote: > Otherwise libbpf is unusable from unprivileged process with > kernel.kernel.unprivileged_bpf_disabled=1. > All I get is EPERM from the probes, even if I just want to > open an ELF object and look at what progs/maps it has. > > Instead of dying on

Re: [PATCH bpf] selftests/bpf: fix bpf_get_current_task

2019-05-17 Thread Daniel Borkmann
On 05/17/2019 06:34 AM, Alexei Starovoitov wrote: > Fix bpf_get_current_task() declaration. > > Signed-off-by: Alexei Starovoitov Applied, thanks!

Re: [PATCH bpf] bpftool: fix BTF raw dump of FWD's fwd_kind

2019-05-17 Thread Daniel Borkmann
On 05/17/2019 08:21 AM, Andrii Nakryiko wrote: > kflag bit determines whether FWD is for struct or union. Use that bit. > > Fixes: c93cc69004df ("bpftool: add ability to dump BTF types") > Signed-off-by: Andrii Nakryiko Applied, thanks!

pull-request: bpf 2019-05-18

2019-05-17 Thread Daniel Borkmann
Hi David, The following pull-request contains BPF updates for your *net* tree. The main changes are: 1) Fix bpftool's raw BTF dump in relation to forward declarations of union/ structs, and another fix to unexport logging helpers, from Andrii. 2) Fix inode permission check for retrieving bpf

Re: [net-next V4 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP

2017-10-05 Thread Daniel Borkmann
On 10/04/2017 02:03 PM, Jesper Dangaard Brouer wrote: [...] +#define CPU_MAP_BULK_SIZE 8 /* 8 == one cacheline on 64-bit archs */ +struct xdp_bulk_queue { + void *q[CPU_MAP_BULK_SIZE]; + unsigned int count; +}; + +/* Struct for every remote "destination" CPU in map */ +struct bpf_cpu

Re: [net-next V4 PATCH 2/5] bpf: XDP_REDIRECT enable use of cpumap

2017-10-05 Thread Daniel Borkmann
On 10/04/2017 02:03 PM, Jesper Dangaard Brouer wrote: This patch connects cpumap to the xdp_do_redirect_map infrastructure. Still no SKB allocation are done yet. The XDP frames are transferred to the other CPU, but they are simply refcnt decremented on the remote CPU. This served as a good ben

Re: [net-next V4 PATCH 3/5] bpf: cpumap xdp_buff to skb conversion and allocation

2017-10-05 Thread Daniel Borkmann
On 10/04/2017 02:03 PM, Jesper Dangaard Brouer wrote: [...] static int cpu_map_kthread_run(void *data) { struct bpf_cpu_map_entry *rcpu = data; set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { + unsigned int processed = 0, drops =

Re: [PATCH net-next v6 0/4] bpf: add two helpers to read perf event enabled/running time

2017-10-05 Thread Daniel Borkmann
On 10/05/2017 10:34 AM, Peter Zijlstra wrote: On Wed, Oct 04, 2017 at 04:00:56PM -0700, David Miller wrote: From: Yonghong Song Date: Mon, 2 Oct 2017 15:42:14 -0700 [Dave, Peter, Previous communcation shows that this patch may potentially have merge conflict with upcoming tip changes in

Re: [PATCH net-next 3/4] selinux: bpf: Add selinux check for eBPF syscall operations

2017-10-05 Thread Daniel Borkmann
On 10/05/2017 03:28 PM, Stephen Smalley wrote: [...] +static int selinux_bpf_prog(struct bpf_prog *prog) +{ + u32 sid = current_sid(); + struct bpf_security_struct *bpfsec; + + bpfsec = prog->aux->security; I haven't looked closely at the bpf code, but is it guaranteed that pr

Re: [PATCH net-next v3 1/2] libbpf: parse maps sections of varying size

2017-10-05 Thread Daniel Borkmann
in the maps section is the same size. Signed-off-by: Craig Gallek Thanks, Acked-by: Daniel Borkmann

Re: [PATCH net-next v3 2/2] libbpf: use map_flags when creating maps

2017-10-05 Thread Daniel Borkmann
On 10/05/2017 04:41 PM, Craig Gallek wrote: From: Craig Gallek This is required to use BPF_MAP_TYPE_LPM_TRIE or any other map type which requires flags. Signed-off-by: Craig Gallek Acked-by: Daniel Borkmann

Re: [PATCH net-next 5/5] bpf: write back the verifier log buffer as it gets filled

2017-10-05 Thread Daniel Borkmann
On 10/05/2017 05:34 PM, Jakub Kicinski wrote: Verifier log buffer can be quite large (up to 16MB currently). As Eric Dumazet points out if we allow multiple verification requests to proceed simultaneously, malicious user may use the verifier as a way of allocating large amounts of unswappable mem

Re: [PATCH net-next 5/5] bpf: write back the verifier log buffer as it gets filled

2017-10-05 Thread Daniel Borkmann
On 10/05/2017 11:26 PM, Jakub Kicinski wrote: On Thu, 05 Oct 2017 23:10:03 +0200, Daniel Borkmann wrote: include/linux/bpf_verifier.h | 7 +++-- kernel/bpf/verifier.c| 64 +++- 2 files changed, 50 insertions(+), 21 deletions(-) diff

Re: [net-next V4 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP

2017-10-06 Thread Daniel Borkmann
On 10/06/2017 12:50 PM, Jesper Dangaard Brouer wrote: On Thu, 05 Oct 2017 11:40:15 +0200 Daniel Borkmann wrote: On 10/04/2017 02:03 PM, Jesper Dangaard Brouer wrote: [...] +#define CPU_MAP_BULK_SIZE 8 /* 8 == one cacheline on 64-bit archs */ +struct xdp_bulk_queue { + void *q

Re: [PATCH net] bpf: fix liveness marking

2017-10-06 Thread Daniel Borkmann
86727929 time ~11 sec ~4 sec Fixes: dc503a8ad984 ("bpf/verifier: track liveness for pruning") Signed-off-by: Alexei Starovoitov LGTM, thanks! Acked-by: Daniel Borkmann

Re: [PATCH] netfilter: xt_bpf: Fix XT_BPF_MODE_FD_PINNED mode of 'xt_bpf_info_v1'

2017-10-09 Thread Daniel Borkmann
Hi Shmulik, On 10/09/2017 01:57 PM, Pablo Neira Ayuso wrote: On Mon, Oct 09, 2017 at 01:18:23PM +0200, Pablo Neira Ayuso wrote: On Fri, Oct 06, 2017 at 01:40:13PM -0400, Willem de Bruijn wrote: On Fri, Oct 6, 2017 at 12:02 PM, Shmulik Ladkani wrote: From: Shmulik Ladkani Commit 2c16d603326

Re: [PATCH v2] netfilter: xt_bpf: Fix XT_BPF_MODE_FD_PINNED mode of 'xt_bpf_info_v1'

2017-10-09 Thread Daniel Borkmann
: [1] https://marc.info/?l=netfilter-devel&m=150564724607440&w=2 [2] https://marc.info/?l=netfilter-devel&m=150575727129880&w=2 Cc: Pablo Neira Ayuso Cc: Willem de Bruijn Reported-by: Rafael Buchbinder Signed-off-by: Shmulik Ladkani Acked-by: Daniel Borkmann

Re: [net-next V5 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP

2017-10-09 Thread Daniel Borkmann
On 10/06/2017 06:12 PM, Jesper Dangaard Brouer wrote: [...] +static struct bpf_map *cpu_map_alloc(union bpf_attr *attr) +{ + struct bpf_cpu_map *cmap; + int err = -ENOMEM; err init here is basically not needed since overriden later anyway w/o being read, but ... + u64 cost;

Re: [net-next V5 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP

2017-10-09 Thread Daniel Borkmann
On 10/09/2017 03:31 PM, Daniel Borkmann wrote: On 10/06/2017 06:12 PM, Jesper Dangaard Brouer wrote: [...] +/* Pre-limit array size based on NR_CPUS, not final CPU check */ +if (cmap->map.max_entries > NR_CPUS) Nit: needs to be >= NR_CPUS. Scratch that comment, you ba

<    4   5   6   7   8   9   10   11   12   13   >