Re: [PATCH bpf v2 1/2] bpf: link: refuse non-O_RDWR flags in BPF_OBJ_GET

2021-03-31 Thread Lorenz Bauer
On Fri, 26 Mar 2021 at 16:05, Lorenz Bauer wrote: > > Invoking BPF_OBJ_GET on a pinned bpf_link checks the path access > permissions based on file_flags, but the returned fd ignores flags. > This means that any user can acquire a "read-write" fd for a pinned > link w

Re: [PATCH v2 bpf-next 00/14] bpf: Support calling kernel function

2021-03-30 Thread Lorenz Bauer
ctory make: *** [Makefile:451: /home/lorenz/dev/kbuild/vm//no_alu32/bpf_dctcp.skel.h] Error 255 make: *** Deleting file '/home/lorenz/dev/kbuild/vm//no_alu32/bpf_dctcp.skel.h' -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [PATCH v2 bpf-next 00/14] bpf: Support calling kernel function

2021-03-29 Thread Lorenz Bauer
_FTRACE and also try 'y' if it > is not set? I hit the same problem on newer pahole: $ pahole --version v1.20 CONFIG_DYNAMIC_FTRACE=y resolves the issue. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [PATCH bpf v2 2/2] bpf: program: refuse non-O_RDWR flags in BPF_OBJ_GET

2021-03-29 Thread Lorenz Bauer
On Fri, 26 Mar 2021 at 20:14, Song Liu wrote: > > On Fri, Mar 26, 2021 at 9:07 AM Lorenz Bauer wrote: > > > > As for bpf_link, refuse creating a non-O_RDWR fd. Since program fds > > currently don't allow modifications this is a precaution, not a > > straigh

[PATCH bpf v2 2/2] bpf: program: refuse non-O_RDWR flags in BPF_OBJ_GET

2021-03-26 Thread Lorenz Bauer
As for bpf_link, refuse creating a non-O_RDWR fd. Since program fds currently don't allow modifications this is a precaution, not a straight up bug fix. Signed-off-by: Lorenz Bauer --- kernel/bpf/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/inod

[PATCH bpf v2 1/2] bpf: link: refuse non-O_RDWR flags in BPF_OBJ_GET

2021-03-26 Thread Lorenz Bauer
ce pinnable bpf_link abstraction") Signed-off-by: Lorenz Bauer --- kernel/bpf/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 1576ff331ee4..dc56237d6960 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -547,7 +547,

Re: [PATCH bpf] bpf: link: refuse non-zero file_flags in BPF_OBJ_GET

2021-03-26 Thread Lorenz Bauer
ce, but the code in question doesn't support that particular flag. EINVAL seemed more appropriate. Happy to change it if you prefer. >And check f_flags, not flags: > > if (f_flags != O_RDWR) > ret = -EACCESS; > else > ret = bpf_link_new_fd(raw); I'll res

[PATCH bpf] bpf: link: refuse non-zero file_flags in BPF_OBJ_GET

2021-03-25 Thread Lorenz Bauer
links, so this change is unlikely to break users. Fixes: 70ed506c3bbc ("bpf: Introduce pinnable bpf_link abstraction") Signed-off-by: Lorenz Bauer --- kernel/bpf/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 1

Re: [PATCH] net: add net namespace inode for all net_dev events

2021-03-10 Thread Lorenz Bauer
t; After 3d368ab87cf6681f9 ("net: initialize net->net_cookie at netns setup") > net->net_cookie is directly available. The patch set is at https://lore.kernel.org/bpf/20210219154330.93615-1-...@cloudflare.com/ but I decided to abandon it. I can work around my issue by comparing the n

Re: [Patch bpf-next v2 2/9] sock: introduce sk_prot->update_proto()

2021-03-04 Thread Lorenz Bauer
as it is, unless you see any other benefits. I think the end result is code that is easier to understand and therefore maintain. Keep it as it is if you prefer. > BTW, I will rename it to 'psock_update_sk_prot', please let me know > if you have any better names. SGTM. -- Lorenz

Re: [Patch bpf-next v2 9/9] selftests/bpf: add a test case for udp sockmap

2021-03-03 Thread Lorenz Bauer
On Tue, 2 Mar 2021 at 18:05, Cong Wang wrote: > > On Tue, Mar 2, 2021 at 8:32 AM Lorenz Bauer wrote: > > > > On Tue, 2 Mar 2021 at 02:38, Cong Wang wrote: > > > > > > From: Cong Wang > > > > > > Add a test case to ensure redirection b

[PATCH bpf-next v4 3/5] selftests: bpf: convert sk_lookup ctx access tests to PROG_TEST_RUN

2021-03-03 Thread Lorenz Bauer
Convert the selftests for sk_lookup narrow context access to use PROG_TEST_RUN instead of creating actual sockets. This ensures that ctx is populated correctly when using PROG_TEST_RUN. Assert concrete values since we now control remote_ip and remote_port. Signed-off-by: Lorenz Bauer

[PATCH bpf-next v4 2/5] bpf: add PROG_TEST_RUN support for sk_lookup programs

2021-03-03 Thread Lorenz Bauer
ocket pointer. We don't support testing programs that select a reuseport socket, since this would mean running another (unrelated) BPF program from the sk_lookup test handler. Signed-off-by: Lorenz Bauer --- include/linux/bpf.h| 10 include/uapi/linux/bpf.h | 5 +

[PATCH bpf-next v4 0/5] PROG_TEST_RUN support for sk_lookup programs

2021-03-03 Thread Lorenz Bauer
_sk_lookup - Drop running multiple programs Lorenz Bauer (5): bpf: consolidate shared test timing code bpf: add PROG_TEST_RUN support for sk_lookup programs selftests: bpf: convert sk_lookup ctx access tests to PROG_TEST_RUN selftests: bpf: check that PROG_TEST_RUN repeats as requested

[PATCH bpf-next v4 4/5] selftests: bpf: check that PROG_TEST_RUN repeats as requested

2021-03-03 Thread Lorenz Bauer
Extend a simple prog_run test to check that PROG_TEST_RUN adheres to the requested repetitions. Convert it to use BPF skeleton. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/prog_run_xattr.c | 51 +++ 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a

[PATCH bpf-next v4 1/5] bpf: consolidate shared test timing code

2021-03-03 Thread Lorenz Bauer
aborting with EINTR we return the successful result to user space. Signed-off-by: Lorenz Bauer --- net/bpf/test_run.c | 141 + 1 file changed, 78 insertions(+), 63 deletions(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 58bcb8c849d5

[PATCH bpf-next v4 5/5] selftests: bpf: don't run sk_lookup in verifier tests

2021-03-03 Thread Lorenz Bauer
have dedicated ctx access tests so skipping here doesn't reduce coverage. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/bpf/test_verifier.c | 4 ++-- tools/testing/selftests/bpf/verifier/ctx_sk_lookup.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff -

Re: [Patch bpf-next v2 2/9] sock: introduce sk_prot->update_proto()

2021-03-03 Thread Lorenz Bauer
oto(sk, psock, prot); > > > - return 0; > > > + psock->saved_update_proto = sk->sk_prot->update_proto; > > > + return sk->sk_prot->update_proto(sk, false); > > > > I think reads / writes from sk_prot need READ_ONCE / WRITE_ONCE. We've > > not been diligent about this so far, but I think it makes sense to be > > careful in new code. > > Hmm, there are many places not using READ_ONCE/WRITE_ONCE, > for a quick example: I know! I'll defer to John and Jakub. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next v2 2/9] sock: introduce sk_prot->update_proto()

2021-03-02 Thread Lorenz Bauer
> - > - if (IS_ERR(prot)) > - return PTR_ERR(prot); > - > - sk_psock_update_proto(sk, psock, prot); > - return 0; > + psock->saved_update_proto = sk->sk_prot->update_proto; > + return sk->sk_prot->update_proto(sk, false); I think reads / writes from sk_prot need READ_ONCE / WRITE_ONCE. We've not been diligent about this so far, but I think it makes sense to be careful in new code. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next v2 9/9] selftests/bpf: add a test case for udp sockmap

2021-03-02 Thread Lorenz Bauer
)? Seems like we don't hook sk_prot->disconnect anywhere. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next v2 5/9] udp: add ->read_sock() and ->sendmsg_locked() to ipv6

2021-03-02 Thread Lorenz Bauer
d; > } > +EXPORT_SYMBOL(udp_read_sock); Should this be in the previous commit? -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [PATCH bpf 2/4] nsfs: add an ioctl to discover the network namespace cookie

2021-03-02 Thread Lorenz Bauer
amespace of the network > namespace? > > Christian Hi Christian, I've decided to drop the patch set for now, but that was my intention, yes. Is there a downside I'm not aware of? Lorenz -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next] skmsg: add function doc for skb->_sk_redir

2021-03-02 Thread Lorenz Bauer
On Mon, 1 Mar 2021 at 18:48, Cong Wang wrote: > > From: Cong Wang > > This should fix the following warning: > > include/linux/skbuff.h:932: warning: Function parameter or member > '_sk_redir' not described in 'sk_buff' Thanks! Acked-by: Lorenz Bauer

Re: [Patch bpf-next v7 4/9] skmsg: move sk_redir from TCP_SKB_CB to skb

2021-03-01 Thread Lorenz Bauer
gt; include/linux/skbuff.h:932: warning: Function parameter or member '_sk_redir' > not described in 'sk_buff' Per-file breakdown Source: https://patchwork.kernel.org/project/netdevbpf/patch/20210223184934.6054-5-xiyou.wangc...@gmail.com/ Maybe something to follow up on, I'

[PATCH bpf-next v3 4/5] selftests: bpf: check that PROG_TEST_RUN repeats as requested

2021-03-01 Thread Lorenz Bauer
Extend a simple prog_run test to check that PROG_TEST_RUN adheres to the requested repetitions. Convert it to use BPF skeleton. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/prog_run_xattr.c | 51 +++ 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a

[PATCH bpf-next v3 5/5] selftests: bpf: don't run sk_lookup in verifier tests

2021-03-01 Thread Lorenz Bauer
have dedicated ctx access tests so skipping here doesn't reduce coverage. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/bpf/test_verifier.c | 4 ++-- tools/testing/selftests/bpf/verifier/ctx_sk_lookup.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff -

[PATCH bpf-next v3 3/5] selftests: bpf: convert sk_lookup ctx access tests to PROG_TEST_RUN

2021-03-01 Thread Lorenz Bauer
Convert the selftests for sk_lookup narrow context access to use PROG_TEST_RUN instead of creating actual sockets. This ensures that ctx is populated correctly when using PROG_TEST_RUN. Assert concrete values since we now control remote_ip and remote_port. Signed-off-by: Lorenz Bauer

[PATCH bpf-next v3 2/5] bpf: add PROG_TEST_RUN support for sk_lookup programs

2021-03-01 Thread Lorenz Bauer
ocket pointer. We don't support testing programs that select a reuseport socket, since this would mean running another (unrelated) BPF program from the sk_lookup test handler. Signed-off-by: Lorenz Bauer --- include/linux/bpf.h| 10 include/uapi/linux/bpf.h | 5 +

[PATCH bpf-next v3 0/5] PROG_TEST_RUN support for sk_lookup programs

2021-03-01 Thread Lorenz Bauer
the v1 I've dropped support for testing multiple programs at once. Changes since v2: - Fix test_verifier failure (Alexei) Changes since v1: - Add sparse annotations to the t_* functions - Add appropriate type casts in bpf_prog_test_run_sk_lookup - Drop running multiple programs Lorenz Baue

[PATCH bpf-next v3 1/5] bpf: consolidate shared test timing code

2021-03-01 Thread Lorenz Bauer
aborting with EINTR we return the successful result to user space. Signed-off-by: Lorenz Bauer --- net/bpf/test_run.c | 141 + 1 file changed, 78 insertions(+), 63 deletions(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 58bcb8c849d5

[PATCH bpf-next v2 4/4] selftests: bpf: check that PROG_TEST_RUN repeats as requested

2021-02-26 Thread Lorenz Bauer
Extend a simple prog_run test to check that PROG_TEST_RUN adheres to the requested repetitions. Convert it to use BPF skeleton. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/prog_run_xattr.c | 51 +++ 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a

[PATCH bpf-next v2 3/4] selftests: bpf: convert sk_lookup ctx access tests to PROG_TEST_RUN

2021-02-26 Thread Lorenz Bauer
Convert the selftests for sk_lookup narrow context access to use PROG_TEST_RUN instead of creating actual sockets. This ensures that ctx is populated correctly when using PROG_TEST_RUN. Assert concrete values since we now control remote_ip and remote_port. Signed-off-by: Lorenz Bauer

[PATCH bpf-next v2 2/4] bpf: add PROG_TEST_RUN support for sk_lookup programs

2021-02-26 Thread Lorenz Bauer
ocket pointer. We don't support testing programs that select a reuseport socket, since this would mean running another (unrelated) BPF program from the sk_lookup test handler. Signed-off-by: Lorenz Bauer --- include/linux/bpf.h| 10 include/uapi/linux/bpf.h | 5 +

[PATCH bpf-next v2 0/5] PROG_TEST_RUN support for sk_lookup programs

2021-02-26 Thread Lorenz Bauer
the v1 I've dropped support for testing multiple programs at once. Changes since v1: - Add sparse annotations to the t_* functions - Add appropriate type casts in bpf_prog_test_run_sk_lookup - Drop running multiple programs Lorenz Bauer (5): bpf: consolidate shared test timing code bpf: add

[PATCH bpf-next v2 1/4] bpf: consolidate shared test timing code

2021-02-26 Thread Lorenz Bauer
aborting with EINTR we return the successful result to user space. Signed-off-by: Lorenz Bauer --- net/bpf/test_run.c | 141 + 1 file changed, 78 insertions(+), 63 deletions(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 58bcb8c849d5

Re: [PATCH bpf-next 0/8] PROG_TEST_RUN support for sk_lookup programs

2021-02-23 Thread Lorenz Bauer
. Doesn't seem like a big deal (and highly unlikely anyways). Ok, thanks! I'm not super familiar with C platform differences, so I wanted to be on the safe side. I'll take this up depending on the outcome of the conversation with Alexey, maybe I don't need to add this after al

Re: [PATCH bpf-next 4/8] bpf: add PROG_TEST_RUN support for sk_lookup programs

2021-02-23 Thread Lorenz Bauer
ams. I'm happy to drop the multiple programs bit, like I mentioned I did it for completeness sake. I care about being able to test or benchmark a single sk_lookup program. Lorenz -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

[PATCH bpf-next v3 4/4] tools/testing: add a selftest for SO_NETNS_COOKIE

2021-02-19 Thread Lorenz Bauer
Make sure that SO_NETNS_COOKIE returns a non-zero value, and that sockets from different namespaces have a distinct cookie value. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/net/.gitignore| 1 + tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests

[PATCH bpf-next v3 0/4] Expose network namespace cookies to user space

2021-02-19 Thread Lorenz Bauer
;s netns cookie simplification Lorenz Bauer (4): net: add SO_NETNS_COOKIE socket option nsfs: add an ioctl to discover the network namespace cookie tools/testing: add test for NS_GET_COOKIE tools/testing: add a selftest for SO_NETNS_COOKIE arch/alpha/include/uapi/asm/socket.h | 2 + arch/mi

[PATCH bpf-next v3 3/4] tools/testing: add test for NS_GET_COOKIE

2021-02-19 Thread Lorenz Bauer
Check that NS_GET_COOKIE returns a non-zero value, and that distinct network namespaces have different cookies. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/nsfs/.gitignore | 1 + tools/testing/selftests/nsfs/Makefile | 2 +- tools/testing/selftests/nsfs/config | 1 + tools

[PATCH bpf-next v3 2/4] nsfs: add an ioctl to discover the network namespace cookie

2021-02-19 Thread Lorenz Bauer
Network namespaces have a globally unique non-zero identifier aka a cookie, in line with socket cookies. Add an ioctl to retrieve the cookie from user space without going via BPF. Signed-off-by: Lorenz Bauer --- fs/nsfs.c | 7 +++ include/uapi/linux/nsfs.h | 2 ++ 2 files

[PATCH bpf-next v3 1/4] net: add SO_NETNS_COOKIE socket option

2021-02-19 Thread Lorenz Bauer
abled, SO_NETNS_COOKIE returns the cookie of init_net. Signed-off-by: Lorenz Bauer --- arch/alpha/include/uapi/asm/socket.h | 2 ++ arch/mips/include/uapi/asm/socket.h | 2 ++ arch/parisc/include/uapi/asm/socket.h | 2 ++ arch/sparc/include/uapi/asm/socket.h | 2 ++ include/uapi/asm-generic/soc

Re: [PATCH bpf-next v2 1/4] net: add SO_NETNS_COOKIE socket option

2021-02-19 Thread Lorenz Bauer
sock_net(sk)->net_cookie; I looked at sock_net and didn't understand how it avoids a compile error so I didn't use it, thanks for pointing this out. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

[PATCH bpf-next v2 4/4] tools/testing: add a selftest for SO_NETNS_COOKIE

2021-02-19 Thread Lorenz Bauer
Make sure that SO_NETNS_COOKIE returns a non-zero value, and that sockets from different namespaces have a distinct cookie value. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/net/.gitignore| 1 + tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests

[PATCH bpf-next v2 3/4] tools/testing: add test for NS_GET_COOKIE

2021-02-19 Thread Lorenz Bauer
Check that NS_GET_COOKIE returns a non-zero value, and that distinct network namespaces have different cookies. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/nsfs/.gitignore | 1 + tools/testing/selftests/nsfs/Makefile | 2 +- tools/testing/selftests/nsfs/config | 1 + tools

[PATCH bpf-next v2 0/4] Expose network namespace cookies to user space

2021-02-19 Thread Lorenz Bauer
es in v2: - Rebase on top of Eric Dumazet's netns cookie simplification Lorenz Bauer (4): net: add SO_NETNS_COOKIE socket option nsfs: add an ioctl to discover the network namespace cookie tools/testing: add test for NS_GET_COOKIE tools/testing: add a selftest for SO_NETNS_COOKIE

[PATCH bpf-next v2 2/4] nsfs: add an ioctl to discover the network namespace cookie

2021-02-19 Thread Lorenz Bauer
Network namespaces have a globally unique non-zero identifier aka a cookie, in line with socket cookies. Add an ioctl to retrieve the cookie from user space without going via BPF. Signed-off-by: Lorenz Bauer --- fs/nsfs.c | 8 include/uapi/linux/nsfs.h | 2 ++ 2 files

[PATCH bpf-next v2 1/4] net: add SO_NETNS_COOKIE socket option

2021-02-19 Thread Lorenz Bauer
abled, SO_NETNS_COOKIE returns the cookie of init_net. Signed-off-by: Lorenz Bauer --- arch/alpha/include/uapi/asm/socket.h | 2 ++ arch/mips/include/uapi/asm/socket.h | 2 ++ arch/parisc/include/uapi/asm/socket.h | 2 ++ arch/sparc/include/uapi/asm/socket.h | 2 ++ include/uapi/asm-generic/soc

[PATCH bpf-next 6/8] selftests: bpf: convert sk_lookup multi prog tests to PROG_TEST_RUN

2021-02-16 Thread Lorenz Bauer
Make the tests for multi program sk_lookup semantics use bpf_prog_run_array. This simplifies the test a bit and adds coverage to the new libbpf function. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/sk_lookup.c | 100 -- 1 file changed, 65 insertions(+), 35

[PATCH bpf-next 8/8] selftests: bpf: check that PROG_TEST_RUN repeats as requested

2021-02-16 Thread Lorenz Bauer
Extend a simple prog_run test to check that PROG_TEST_RUN adheres to the requested repetitions. Convert it to use BPF skeleton. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/prog_run_xattr.c | 51 +++ 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a

[PATCH bpf-next 7/8] selftests: bpf: convert sk_lookup ctx access tests to PROG_TEST_RUN

2021-02-16 Thread Lorenz Bauer
Convert the selftests for sk_lookup narrow context access to use PROG_TEST_RUN instead of creating actual sockets. This ensures that ctx is populated correctly when using PROG_TEST_RUN. Assert concrete values since we now control remote_ip and remote_port. Signed-off-by: Lorenz Bauer

[PATCH bpf-next 5/8] tools: libbpf: allow testing program types with multi-prog semantics

2021-02-16 Thread Lorenz Bauer
Add a wrapper bpf_prog_test_run_array that allows testing multiple programs for supported program types. Signed-off-by: Lorenz Bauer --- tools/lib/bpf/bpf.c | 16 +++- tools/lib/bpf/bpf.h | 3 +++ tools/lib/bpf/libbpf.map | 1 + 3 files changed, 19 insertions(+), 1

[PATCH bpf-next 4/8] bpf: add PROG_TEST_RUN support for sk_lookup programs

2021-02-16 Thread Lorenz Bauer
f the socket pointer. We don't support testing programs that select a reuseport socket, since this would mean running another (unrelated) BPF program from the sk_lookup test handler. Signed-off-by: Lorenz Bauer --- include/linux/bpf.h| 10 include/uapi/linux/bpf.h |

[PATCH bpf-next 2/8] bpf: add for_each_bpf_prog helper

2021-02-16 Thread Lorenz Bauer
Add a helper to iterate bpf_prog_arrays, which are a hybrid between and array and a linked list. Hide this behind a for each macro. Signed-off-by: Lorenz Bauer --- include/linux/bpf.h| 11 +-- include/linux/filter.h | 4 +--- 2 files changed, 6 insertions(+), 9 deletions(-) diff

[PATCH bpf-next 3/8] bpf: allow multiple programs in BPF_PROG_TEST_RUN

2021-02-16 Thread Lorenz Bauer
to current behaviour. Program types that allow multiple programs have to provide a new test_run_array callback. Signed-off-by: Lorenz Bauer --- include/linux/bpf-netns.h | 2 + include/linux/bpf.h| 3 ++ include/uapi/linux/bpf.h | 6 ++- kernel/bpf/net_namespace.c

[PATCH bpf-next 0/8] PROG_TEST_RUN support for sk_lookup programs

2021-02-16 Thread Lorenz Bauer
e better to take int *prog_fds, but I think then the function would have to convert the array to account for platforms where sizeof(int) != sizeof(__u32) Please let me know what your preference is. Lorenz Bauer (8): bpf: consolidate shared test timing code bpf: add for_each_bpf_pro

[PATCH bpf-next 1/8] bpf: consolidate shared test timing code

2021-02-16 Thread Lorenz Bauer
aborting with EINTR we return the successful result to user space. Signed-off-by: Lorenz Bauer --- net/bpf/test_run.c | 137 + 1 file changed, 76 insertions(+), 61 deletions(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 58bcb8c849d5

Re: [Patch bpf-next v3 4/5] skmsg: use skb ext instead of TCP_SKB_CB

2021-02-16 Thread Lorenz Bauer
playing with skb cb, which is harder to make > > correct. > > > > Cc: John Fastabend > > Cc: Daniel Borkmann > > Cc: Jakub Sitnicki > > Reviewed-by: Lorenz Bauer > > Signed-off-by: Cong Wang > > --- > > I'm not seeing the advantage of

Re: [Patch bpf-next v3 1/5] bpf: clean up sockmap related Kconfigs

2021-02-15 Thread Lorenz Bauer
epend on CONFIG_BPF_SYSCALL. > And leave CONFIG_NET_SOCK_MSG untouched, as it is used by > non-sockmap cases. For the series: Reviewed-by: Lorenz Bauer Jakub, John: can you please take another look at the assembly in patch 3? -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/Th

Re: [Patch bpf-next v2 5/5] sock_map: rename skb_parser and skb_verdict

2021-02-12 Thread Lorenz Bauer
general use later. Reviewed-by: Lorenz Bauer -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next v2 4/5] skmsg: use skb ext instead of TCP_SKB_CB

2021-02-12 Thread Lorenz Bauer
correct. Reviewed-by: Lorenz Bauer -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next v2 2/5] skmsg: get rid of struct sk_psock_parser

2021-02-12 Thread Lorenz Bauer
d. Looks nice, can you use sk_psock_strp_enabled() more? There are a couple places in sock_map.c which test psock->saved_data_ready directly. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next v2 3/5] bpf: compute data_end dynamically with JIT code

2021-02-12 Thread Lorenz Bauer
d of ->data_end. This is similar to skb_shinfo(skb) computation > in bpf_convert_shinfo_access(). > > Suggested-by: Jakub Sitnicki > Cc: John Fastabend > Cc: Daniel Borkmann > Cc: Lorenz Bauer > Signed-off-by: Cong Wang ... > @@ -9520,6 +9510,29 @@ static u32 sock_

Re: [PATCH net-next] net: initialize net->net_cookie at netns setup

2021-02-11 Thread Lorenz Bauer
On Wed, 10 Feb 2021 at 14:41, Eric Dumazet wrote: > > From: Eric Dumazet > > It is simpler to make net->net_cookie a plain u64 > written once in setup_net() instead of looping > and using atomic64 helpers. > > Lorenz Bauer wants to add SO_NETNS_COOKIE socket option &

[PATCH bpf 4/4] tools/testing: add a selftest for SO_NETNS_COOKIE

2021-02-10 Thread Lorenz Bauer
Make sure that SO_NETNS_COOKIE returns a non-zero value, and that sockets from different namespaces have a distinct cookie value. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/net/.gitignore| 1 + tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests

[PATCH bpf 0/4] Expose network namespace cookies to user space

2021-02-10 Thread Lorenz Bauer
Cc: linux-ker...@vger.kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-m...@vger.kernel.org Cc: linux-par...@vger.kernel.org Cc: netdev@vger.kernel.org Cc: sparcli...@vger.kernel.org Lorenz Bauer (4): net: add SO_NETNS_COOKIE socket option nsfs: add an ioctl to discover the network namespa

[PATCH bpf 3/4] tools/testing: add test for NS_GET_COOKIE

2021-02-10 Thread Lorenz Bauer
Check that NS_GET_COOKIE returns a non-zero value, and that distinct network namespaces have different cookies. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/nsfs/.gitignore | 1 + tools/testing/selftests/nsfs/Makefile | 2 +- tools/testing/selftests/nsfs/netns.c| 57

[PATCH bpf 2/4] nsfs: add an ioctl to discover the network namespace cookie

2021-02-10 Thread Lorenz Bauer
Network namespaces have a globally unique non-zero identifier aka a cookie, in line with socket cookies. Add an ioctl to retrieve the cookie from user space without going via BPF. Cc: linux-...@vger.kernel.org Signed-off-by: Lorenz Bauer --- fs/nsfs.c | 9 + include

[PATCH bpf 1/4] net: add SO_NETNS_COOKIE socket option

2021-02-10 Thread Lorenz Bauer
abled, SO_NETNS_COOKIE returns the cookie of init_net. The BPF helpers change slightly: instead of returning 0 when network namespaces are disabled we return the init_net cookie as for the socket option. Cc: linux-...@vger.kernel.org Signed-off-by: Lorenz Bauer --- arch/alpha/include/uapi/asm/socket.h

Re: [Patch bpf-next 01/19] bpf: rename BPF_STREAM_PARSER to BPF_SOCK_MAP

2021-02-08 Thread Lorenz Bauer
ll be fine. So sockmap would not be hidden behind a CONFIG anymore? That would be great. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [Patch bpf-next 08/19] udp: implement ->read_sock() for sockmap

2021-02-08 Thread Lorenz Bauer
On Wed, 3 Feb 2021 at 04:17, Cong Wang wrote: > > From: Cong Wang > > Cc: John Fastabend > Cc: Daniel Borkmann > Cc: Jakub Sitnicki > Cc: Lorenz Bauer > Signed-off-by: Cong Wang > --- > include/net/udp.h | 2 ++ > net/ipv4/af_inet.c

Re: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Lorenz Bauer
p_area_alloc although that might conflict with Fixes tag. Lorenz -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

[PATCH bpf] tools/bpftool: fix attaching flow dissector

2020-11-05 Thread Lorenz Bauer
gs to BPF_PROG_ATTACH") Reported-by: Jiri Benc Signed-off-by: Lorenz Bauer --- tools/bpf/bpftool/prog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index d942c1e3372c..acdb2c245f0a 100644 --- a/tools/bpf/bpftool/prog.c +++ b

Re: [PATCH bpf-next V3 3/6] bpf: add BPF-helper for MTU checking

2020-10-12 Thread Lorenz Bauer
needed for > + * implemeting PMTU handing: > + * > + * * **BPF_MTU_CHK_RET_FRAG_NEEDED** > + * * **BPF_MTU_CHK_RET_GSO_TOOBIG** > + * -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

[PATCH bpf] bpf: sockmap: add locking annotations to iterator

2020-10-12 Thread Lorenz Bauer
I used what is easier to type out. Fixes: 0365351524d7 ("net: Allow iterating sockmap and sockhash") Reported-by: kernel test robot Signed-off-by: Lorenz Bauer --- net/core/sock_map.c | 8 1 file changed, 8 insertions(+) diff --git a/net/core/sock_map.c b/net/core/sock_map

Re: [PATCH bpf-next v2 2/4] selftests: bpf: Add helper to compare socket cookies

2020-10-02 Thread Lorenz Bauer
tps://godbolt.org/z/77P6P9 Seems like red hat GCC has some special sauce that fixes this behaviour? -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [PATCH bpf-next v2 4/4] selftest: bpf: Test copying a sockmap and sockhash

2020-09-30 Thread Lorenz Bauer
ught the key arg should be used as read-only in the map's helper. > or there is map type's helper that modifies the key? I don't know, that's what I meant by more difficult. If map keys are always read-only like you say this would be straight forward to do (famous last w

Re: [PATCH bpf-next v2 2/4] selftests: bpf: Add helper to compare socket cookies

2020-09-30 Thread Lorenz Bauer
l warning.c jkbs@toad ~/tmp $ Maybe this is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501 ? The problem is still there on gcc 10. Compiling test_progs with clang does issue a warning FWIW, but it seems like other things break when doing that. -- Lorenz Bauer | Systems Eng

[PATCH bpf-next v3 4/4] selftest: bpf: Test copying a sockmap and sockhash

2020-09-29 Thread Lorenz Bauer
Since we can now call map_update_elem(sockmap) from bpf_iter context it's possible to copy a sockmap or sockhash in the kernel. Add a selftest which exercises this. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/sockmap_basic.c | 14 +- .../selftests/bpf/

[PATCH bpf-next v3 0/4] [PATCH bpf-next v2 0/4] Sockmap copying

2020-09-29 Thread Lorenz Bauer
thanks to the ground work from Martin, whose series [1] this patch is based on. I updated the tests to do some copying, and also included two cleanups. 1: https://lore.kernel.org/bpf/20200925000337.3853598-1-ka...@fb.com/ Lorenz Bauer (4): bpf: sockmap: enable map_update_elem from bpf_iter

[PATCH bpf-next v3 2/4] selftests: bpf: Add helper to compare socket cookies

2020-09-29 Thread Lorenz Bauer
We compare socket cookies to ensure that insertion into a sockmap worked. Pull this out into a helper function for use in other tests. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/sockmap_basic.c | 50 +-- 1 file changed, 36 insertions(+), 14 deletions(-) diff

[PATCH bpf-next v3 1/4] bpf: sockmap: enable map_update_elem from bpf_iter

2020-09-29 Thread Lorenz Bauer
sk_fullsock. Doing this allows calling map_update_elem on sockmap from bpf_iter context, which uses BTF pointers. Signed-off-by: Lorenz Bauer Acked-by: Martin KaFai Lau --- kernel/bpf/verifier.c | 2 +- net/core/sock_map.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel

[PATCH bpf-next v3 3/4] selftests: bpf: remove shared header from sockmap iter test

2020-09-29 Thread Lorenz Bauer
The shared header to define SOCKMAP_MAX_ENTRIES is a bit overkill. Dynamically allocate the sock_fd array based on bpf_map__max_entries instead. Suggested-by: Yonghong Song Signed-off-by: Lorenz Bauer Acked-by: Yonghong Song --- .../selftests/bpf/prog_tests/sockmap_basic.c | 36

Re: [PATCH bpf-next v2 4/4] selftest: bpf: Test copying a sockmap and sockhash

2020-09-29 Thread Lorenz Bauer
rnatively, allow specialising map_ops per context. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

[PATCH bpf-next v2 2/4] selftests: bpf: Add helper to compare socket cookies

2020-09-28 Thread Lorenz Bauer
We compare socket cookies to ensure that insertion into a sockmap worked. Pull this out into a helper function for use in other tests. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/sockmap_basic.c | 50 +-- 1 file changed, 36 insertions(+), 14 deletions(-) diff

[PATCH bpf-next v2 4/4] selftest: bpf: Test copying a sockmap and sockhash

2020-09-28 Thread Lorenz Bauer
Since we can now call map_update_elem(sockmap) from bpf_iter context it's possible to copy a sockmap or sockhash in the kernel. Add a selftest which exercises this. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/sockmap_basic.c | 14 +- .../selftests/bpf/

[PATCH bpf-next v2 1/4] bpf: sockmap: enable map_update_elem from bpf_iter

2020-09-28 Thread Lorenz Bauer
sk_fullsock. Doing this allows calling map_update_elem on sockmap from bpf_iter context, which uses BTF pointers. Signed-off-by: Lorenz Bauer --- kernel/bpf/verifier.c | 2 +- net/core/sock_map.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf

[PATCH bpf-next v2 3/4] selftests: bpf: remove shared header from sockmap iter test

2020-09-28 Thread Lorenz Bauer
The shared header to define SOCKMAP_MAX_ENTRIES is a bit overkill. Dynamically allocate the sock_fd array based on bpf_map__max_entries instead. Suggested-by: Yonghong Song Signed-off-by: Lorenz Bauer Acked-by: Yonghong Song --- .../selftests/bpf/prog_tests/sockmap_basic.c | 36

[PATCH bpf-next v2 0/4] Sockmap copying

2020-09-28 Thread Lorenz Bauer
.3853598-1-ka...@fb.com/ Lorenz Bauer (4): bpf: sockmap: enable map_update_elem from bpf_iter selftests: bpf: Add helper to compare socket cookies selftests: bpf: remove shared header from sockmap iter test selftest: bpf: Test copying a sockmap and sockhash kernel/bpf/

Re: [PATCH bpf-next 1/4] bpf: sockmap: enable map_update_elem from bpf_iter

2020-09-28 Thread Lorenz Bauer
uitable(). > sk_type is not in sock_common. Oh my, thanks! -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com

Re: [PATCH v4 bpf-next 02/13] bpf: Enable bpf_skc_to_* sock casting helper to networking prog type

2020-09-25 Thread Lorenz Bauer
On Fri, 25 Sep 2020 at 14:18, Martin KaFai Lau wrote: > > On Fri, Sep 25, 2020 at 09:26:36AM +0100, Lorenz Bauer wrote: > > On Fri, 25 Sep 2020 at 01:04, Martin KaFai Lau wrote: > > > > > > There is a constant need to add more fields into the bpf_tcp_sock > >

[PATCH bpf-next 2/4] selftests: bpf: Add helper to compare socket cookies

2020-09-25 Thread Lorenz Bauer
We compare socket cookies to ensure that insertion into a sockmap worked. Pull this out into a helper function for use in other tests. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/sockmap_basic.c | 50 +-- 1 file changed, 36 insertions(+), 14 deletions(-) diff

[PATCH bpf-next 4/4] selftest: bpf: Test copying a sockmap and sockhash

2020-09-25 Thread Lorenz Bauer
Since we can now call map_update_elem(sockmap) from bpf_iter context it's possible to copy a sockmap or sockhash in the kernel. Add a selftest which exercises this. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/sockmap_basic.c | 14 +- .../selftests/bpf/

[PATCH bpf-next 3/4] bpf: selftests: remove shared header from sockmap iter test

2020-09-25 Thread Lorenz Bauer
The shared header to define SOCKMAP_MAX_ENTRIES is a bit overkill. Dynamically allocate the sock_fd array based on bpf_map__max_entries instead. Suggested-by: Yonghong Song Signed-off-by: Lorenz Bauer Acked-by: Yonghong Song --- .../selftests/bpf/prog_tests/sockmap_basic.c | 36

[PATCH bpf-next 0/4] Sockmap copying

2020-09-25 Thread Lorenz Bauer
included two cleanups. I'm sending this out now rather than when Martin's series has landed because I hope this can get in before the merge window (potentially) closes this weekend. 1: https://lore.kernel.org/bpf/20200925000337.3853598-1-ka...@fb.com/ Lorenz Bauer (4): bpf: sockm

[PATCH bpf-next 1/4] bpf: sockmap: enable map_update_elem from bpf_iter

2020-09-25 Thread Lorenz Bauer
uses BTF pointers. Signed-off-by: Lorenz Bauer --- kernel/bpf/verifier.c | 2 +- net/core/sock_map.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index d4ba29fb17a6..5bd0239da8b6 100644 --- a/kernel/bpf/verifier.c +++ b

Re: [PATCH v4 bpf-next 00/13] bpf: Enable bpf_skc_to_* sock casting helper to networking prog type

2020-09-25 Thread Lorenz Bauer
ref_tracking verifier test for bpf_skc casting > bpf: selftest: Move sock_fields test into test_progs > bpf: selftest: Adapt sock_fields test to use skel and global variables > bpf: selftest: Use network_helpers in the sock_fields test > bpf: selftest: Use bpf_skc_to_tcp_sock() i

Re: [bpf-next PATCH] bpf: Add comment to document BTF type PTR_TO_BTF_ID_OR_NULL

2020-09-25 Thread Lorenz Bauer
w type that we > can ensure is non-null for branch analysis and also passing into > helpers. Yeah, I was going back and forth with Martin on this as well. I think we need better descriptions for possibly-NULL-at-runtime for the purpose of helper call invariants, and possibly-NULL-at-verificat

Re: [PATCH v4 bpf-next 07/13] bpf: selftest: Add ref_tracking verifier test for bpf_skc casting

2020-09-25 Thread Lorenz Bauer
On Fri, 25 Sep 2020 at 01:04, Martin KaFai Lau wrote: > > The patch tests for: > 1. bpf_sk_release() can be called on a tcp_sock btf_id ptr. > > 2. Ensure the tcp_sock btf_id pointer cannot be used >after bpf_sk_release(). > > Signed-off-by: Martin KaFai Lau

Re: [PATCH v4 bpf-next 02/13] bpf: Enable bpf_skc_to_* sock casting helper to networking prog type

2020-09-25 Thread Lorenz Bauer
0,7 +,37 @@ const struct bpf_func_proto > bpf_skc_to_udp6_sock_proto = { > .func = bpf_skc_to_udp6_sock, > .gpl_only = false, > .ret_type = RET_PTR_TO_BTF_ID_OR_NULL, > - .arg1_type = ARG_PTR_TO_BTF_ID, &g

  1   2   3   4   >