Re: [PATCH bpf-next 0/2] Allow mmap of /sys/kernel/btf/vmlinux

2025-05-01 Thread Daniel Xu
On Thu, May 1, 2025, at 7:28 AM, Lorenz Bauer wrote: > I'd like to cut down the memory usage of parsing vmlinux BTF in ebpf-go. > With some upcoming changes the library is sitting at 5MiB for a parse. > Most of that memory is simply copying the BTF blob into user space. > By allowing vmlinux BTF to

[RFC bpf-next 08/13] selftests: bpf: Avoid attaching to bpf_check()

2025-04-09 Thread Daniel Xu
bpf_check(), as it currently exists, will soon be going away to make way for loadable BPF verifier support. Fixup selftests so they fentry attach to a more reliable location. Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/progs/exceptions_assert.c | 2 +- tools/testing/selftests/bpf

[PATCH bpf-next v2 2/3] bpf: selftests: Test constant key extraction on irrelevant maps

2025-02-04 Thread Daniel Xu
Test that very high constant map keys are not interpreted as an error value by the verifier. This would previously fail. Acked-by: Eduard Zingerman Signed-off-by: Daniel Xu --- .../selftests/bpf/progs/verifier_array_access.c | 15 +++ 1 file changed, 15 insertions(+) diff --git

[PATCH bpf-next v2 0/3] bpf: Some fixes for nullness elision

2025-02-04 Thread Daniel Xu
Two fixes for nullness elision. See commits for more details. === Changelog === Changes from v1: * Reword commit message in patch 1 * Add tags Daniel Xu (3): bpf: verifier: Do not extract constant map keys for irrelevant maps bpf: selftests: Test constant key extraction on irrelevant maps

[PATCH bpf-next 2/3] bpf: selftests: Test constant key extraction on irrelevant maps

2025-02-01 Thread Daniel Xu
Test that very high constant map keys are not interpreted as an error value by the verifier. This would previously fail. Signed-off-by: Daniel Xu --- .../selftests/bpf/progs/verifier_array_access.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests

[PATCH bpf-next 0/3] bpf: Some fixes for nullness elision

2025-02-01 Thread Daniel Xu
Two fixes for nullness elision. See commits for more details. Daniel Xu (3): bpf: verifier: Do not extract constant map keys for irrelevant maps bpf: selftests: Test constant key extraction on irrelevant maps bpf: verifier: Disambiguate get_constant_map_key() errors kernel/bpf/verifier.c

Re: [PATCH bpf-next v7 4/5] bpf: verifier: Support eliding map lookup nullness

2025-02-01 Thread Daniel Xu
On Thu, Jan 30, 2025, at 7:41 PM, Daniel Xu wrote: > Hi Ilya, > > On Thu, Jan 30, 2025, at 2:06 AM, Ilya Leoshkevich wrote: >> On Wed, 2025-01-29 at 10:45 -0700, Daniel Xu wrote: >>> On Wed, Jan 29, 2025 at 09:49:12AM -0700, Daniel Xu wrote: >>> > Hi Ilya,

Re: [PATCH] selftests: bpf: Support dynamic linking LLVM if static not available

2025-02-01 Thread Daniel Xu
Hi Yonghong, On Thu, Jan 30, 2025 at 10:28:11PM -0800, Yonghong Song wrote: > > > > On 1/30/25 2:33 PM, Daniel Xu wrote: > > Since 67ab80a01886 ("selftests/bpf: Prefer static linking for LLVM > > libraries"), only statically linking test_progs is support

[PATCH] selftests: bpf: Support dynamic linking LLVM if static not available

2025-01-30 Thread Daniel Xu
e. If both options are available, static linking is chosen. Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/Makefile | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 67

Re: [PATCH bpf-next v7 4/5] bpf: verifier: Support eliding map lookup nullness

2025-01-30 Thread Daniel Xu
Hi Ilya, On Thu, Jan 30, 2025, at 2:06 AM, Ilya Leoshkevich wrote: > On Wed, 2025-01-29 at 10:45 -0700, Daniel Xu wrote: >> On Wed, Jan 29, 2025 at 09:49:12AM -0700, Daniel Xu wrote: >> > Hi Ilya, >> > >> > On Wed, Jan 29, 2025 at 03:58:54PM +0100, Ilya Leosh

Re: [PATCH bpf-next v7 4/5] bpf: verifier: Support eliding map lookup nullness

2025-01-29 Thread Daniel Xu
On Wed, Jan 29, 2025 at 09:49:12AM -0700, Daniel Xu wrote: > Hi Ilya, > > On Wed, Jan 29, 2025 at 03:58:54PM +0100, Ilya Leoshkevich wrote: > > On Tue, 2025-01-14 at 13:28 -0700, Daniel Xu wrote: > > > This commit allows progs to elide a null check on statically known >

Re: [PATCH bpf-next v7 4/5] bpf: verifier: Support eliding map lookup nullness

2025-01-29 Thread Daniel Xu
Hi Ilya, On Wed, Jan 29, 2025 at 03:58:54PM +0100, Ilya Leoshkevich wrote: > On Tue, 2025-01-14 at 13:28 -0700, Daniel Xu wrote: > > This commit allows progs to elide a null check on statically known > > map > > lookup keys. In other words, if the verifier can statically p

[PATCH bpf-next v7 5/5] bpf: selftests: verifier: Add nullness elision tests

2025-01-14 Thread Daniel Xu
ointer. So check that we disallow both. Signed-off-by: Daniel Xu --- .../bpf/progs/verifier_array_access.c | 188 ++ 1 file changed, 188 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/verifier_array_access.c b/tools/testing/selftests/bpf/progs/verifier_arra

[PATCH bpf-next v7 3/5] bpf: verifier: Refactor helper access type tracking

2025-01-14 Thread Daniel Xu
. An additional benefit is the verifier logs are also more precise. For this particular error, users will enjoy a slightly clearer message. See included selftest updates for examples. Acked-by: Eduard Zingerman Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c | 45

[PATCH bpf-next v7 4/5] bpf: verifier: Support eliding map lookup nullness

2025-01-14 Thread Daniel Xu
d in sync with these changes, as the verifier is more efficient with this change. Notable, iters.c tests had to be changed to use a map type that still requires null checks, as it's exercising verifier tracking logic w.r.t iterators. Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c

[PATCH bpf-next v7 0/5] Support eliding map lookup nullness

2025-01-14 Thread Daniel Xu
elision * Added test case for when R2 can be both const and non-const Daniel Xu (5): bpf: verifier: Add missing newline on verbose() call bpf: tcp: Mark bpf_load_hdr_opt() arg2 as read-write bpf: verifier: Refactor helper access type tracking bpf: verifier: Support eliding map lookup nulln

[PATCH bpf-next] bpf: veristat: Document verifier log dumping capability

2025-01-09 Thread Daniel Xu
: Daniel Xu --- tools/testing/selftests/bpf/veristat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c index 974c808f9321..7d0a9cb753e3 100644 --- a/tools/testing/selftests/bpf/veristat.c

Re: [PATCH bpf-next v6 4/5] bpf: verifier: Support eliding map lookup nullness

2025-01-09 Thread Daniel Xu
On Thu, Jan 02, 2025 at 06:53:54PM -0800, Eduard Zingerman wrote: > On Thu, 2024-12-19 at 21:09 -0700, Daniel Xu wrote: > > lgtm, but please see a note below. > > [...] > > > +/* Returns constant key value if possible, else negative error */ > > +static s

[PATCH bpf-next v6 5/5] bpf: selftests: verifier: Add nullness elision tests

2024-12-19 Thread Daniel Xu
ointer. So check that we disallow both. Signed-off-by: Daniel Xu --- .../bpf/progs/verifier_array_access.c | 168 ++ 1 file changed, 168 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/verifier_array_access.c b/tools/testing/selftests/bpf/progs/verifier_arra

[PATCH bpf-next v6 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-19 Thread Daniel Xu
d in sync with these changes, as the verifier is more efficient with this change. Notable, iters.c tests had to be changed to use a map type that still requires null checks, as it's exercising verifier tracking logic w.r.t iterators. Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c

[PATCH bpf-next v6 3/5] bpf: verifier: Refactor helper access type tracking

2024-12-19 Thread Daniel Xu
. An additional benefit is the verifier logs are also more precise. For this particular error, users will enjoy a slightly clearer message. See included selftest updates for examples. Acked-by: Eduard Zingerman Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c | 45

[PATCH bpf-next v6 0/5] Support eliding map lookup nullness

2024-12-19 Thread Daniel Xu
* Added a check for when R2 is not a ptr to stack * Added a check for when stack is uninitialized (no stack slot yet) * Updated existing tests to account for null elision * Added test case for when R2 can be both const and non-const Daniel Xu (5): bpf: verifier: Add missing newline on verbose() c

Re: [PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-19 Thread Daniel Xu
On Thu, Dec 19, 2024 at 04:49:13PM -0800, Alexei Starovoitov wrote: > On Thu, Dec 19, 2024 at 4:43 PM Eduard Zingerman wrote: > > > > On Thu, 2024-12-19 at 17:40 -0700, Daniel Xu wrote: > > > > [...] > > > > > > Ok, thinking a bit more, the best tes

Re: [PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-19 Thread Daniel Xu
On Thu, Dec 19, 2024 at 04:04:43PM -0800, Eduard Zingerman wrote: > On Thu, 2024-12-19 at 14:41 -0700, Daniel Xu wrote: > > [...] > > > > > I think that if test operates on a key like: > > > > > > > > valid key 15 > > > >

Re: [PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-19 Thread Daniel Xu
On Mon, Dec 16, 2024 at 03:24:01PM -0800, Andrii Nakryiko wrote: > On Fri, Dec 13, 2024 at 7:13 PM Eduard Zingerman wrote: > > > > On Fri, 2024-12-13 at 19:44 -0700, Daniel Xu wrote: > > > > [...] > > > > > > > + /* First handle precisely t

Re: [PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-18 Thread Daniel Xu
On Mon, Dec 16, 2024 at 03:24:01PM -0800, Andrii Nakryiko wrote: > On Fri, Dec 13, 2024 at 7:13 PM Eduard Zingerman wrote: > > > > On Fri, 2024-12-13 at 19:44 -0700, Daniel Xu wrote: > > [...] > > > > > > with Eduard's suggestion this also becomes

Re: [PATCH bpf-next v5 5/5] bpf: selftests: verifier: Add nullness elision tests

2024-12-17 Thread Daniel Xu
On Fri, Dec 13, 2024, at 10:17 PM, Eduard Zingerman wrote: > On Thu, 2024-12-12 at 16:22 -0700, Daniel Xu wrote: >> Test that nullness elision works for common use cases. For example, we >> want to check that both full and subreg stack slots are recognized. As >> well as wh

Re: [PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-13 Thread Daniel Xu
On Fri, Dec 13, 2024 at 03:02:11PM GMT, Andrii Nakryiko wrote: > On Thu, Dec 12, 2024 at 3:23 PM Daniel Xu wrote: > > > > This commit allows progs to elide a null check on statically known map > > lookup keys. In other words, if the verifier can statically prove that >

Re: [PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-13 Thread Daniel Xu
On Thu, Dec 12, 2024 at 08:04:45PM GMT, Eduard Zingerman wrote: > On Thu, 2024-12-12 at 16:22 -0700, Daniel Xu wrote: > > I think these changes are fine in general, but see below. > > > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > > index 58b36cc96

Re: [PATCH bpf-next v5 3/5] bpf: verifier: Refactor helper access type tracking

2024-12-13 Thread Daniel Xu
On Thu, Dec 12, 2024 at 08:04:28PM GMT, Eduard Zingerman wrote: > On Thu, 2024-12-12 at 16:22 -0700, Daniel Xu wrote: > > Previously, the verifier was treating all PTR_TO_STACK registers passed > > to a helper call as potentially written to by the helper. However, a

[PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness

2024-12-12 Thread Daniel Xu
d in sync with these changes, as the verifier is more efficient with this change. Notable, iters.c tests had to be changed to use a map type that still requires null checks, as it's exercising verifier tracking logic w.r.t iterators. Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c

[PATCH bpf-next v5 5/5] bpf: selftests: verifier: Add nullness elision tests

2024-12-12 Thread Daniel Xu
Test that nullness elision works for common use cases. For example, we want to check that both full and subreg stack slots are recognized. As well as when there's both const and non-const values of R2 leading up to a lookup. And obviously some bound checks. Signed-off-by: Daniel Xu --- ..

[PATCH bpf-next v5 3/5] bpf: verifier: Refactor helper access type tracking

2024-12-12 Thread Daniel Xu
. An additional benefit is the verifier logs are also more precise. For this particular error, users will enjoy a slightly clearer message. See included selftest updates for examples. Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c | 45 +++ .../testing

[PATCH bpf-next v5 0/5] Support eliding map lookup nullness

2024-12-12 Thread Daniel Xu
ck for when stack is uninitialized (no stack slot yet) * Updated existing tests to account for null elision * Added test case for when R2 can be both const and non-const Daniel Xu (5): bpf: verifier: Add missing newline on verbose() call bpf: tcp: Mark bpf_load_hdr_opt() arg2 as read-write bpf

[PATCH net v3 2/2] selftests: drv-net: rss_ctx: Add test for ntuple rule

2024-11-27 Thread Daniel Xu
Extend the rss_ctx test suite to test that an ntuple action that redirects to an RSS context contains that information in `ethtool -n`. Otherwise the output from ethtool is highly deceiving. This test helps ensure drivers are compliant with the API. Signed-off-by: Daniel Xu --- tools/testing

[PATCH net v3 0/2] bnxt: Fix failure to report RSS context in ntuple rule

2024-11-27 Thread Daniel Xu
to net instead of net-next * Make regex work with ethtool output changes Changes from v1: * Add selftest in patch 2 Daniel Xu (2): bnxt_en: ethtool: Supply ntuple rss context action selftests: drv-net: rss_ctx: Add test for ntuple rule drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 8

Re: [PATCH net v2 2/2] selftests: drv-net: rss_ctx: Add test for ntuple rule

2024-11-12 Thread Daniel Xu
Hi Jakub, On Tue, Nov 12, 2024, at 5:44 PM, Jakub Kicinski wrote: > On Mon, 11 Nov 2024 19:23:31 -0700 Daniel Xu wrote: >> Extend the rss_ctx test suite to test that an ntuple action that >> redirects to an RSS context contains that information in `ethtool -n`. >> Othe

Re: [PATCH net v2 2/2] selftests: drv-net: rss_ctx: Add test for ntuple rule

2024-11-12 Thread Daniel Xu
Hi Ed, On Tue, Nov 12, 2024, at 3:10 AM, Edward Cree wrote: > On 12/11/2024 02:23, Daniel Xu wrote: >> Extend the rss_ctx test suite to test that an ntuple action that >> redirects to an RSS context contains that information in `ethtool -n`. >> Otherwise the output f

[PATCH net v2 0/2] bnxt: Fix failure to report RSS context in ntuple rule

2024-11-11 Thread Daniel Xu
This patchset fixes a bug where bnxt driver was failing to report that an ntuple rule is redirecting to an RSS context. First commit is the fix, then second commit extends selftests to detect if other/new drivers are compliant with ntuple/rss_ctx API. Daniel Xu (2): bnxt_en: ethtool: Supply

[PATCH net v2 2/2] selftests: drv-net: rss_ctx: Add test for ntuple rule

2024-11-11 Thread Daniel Xu
Extend the rss_ctx test suite to test that an ntuple action that redirects to an RSS context contains that information in `ethtool -n`. Otherwise the output from ethtool is highly deceiving. This test helps ensure drivers are compliant with the API. Signed-off-by: Daniel Xu --- tools/testing

[PATCH bpf-next v4 2/2] bpf: selftests: verifier: Add nullness elision tests

2024-10-02 Thread Daniel Xu
d-off-by: Daniel Xu --- .../bpf/progs/verifier_array_access.c | 183 ++ 1 file changed, 183 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/verifier_array_access.c b/tools/testing/selftests/bpf/progs/verifier_array_access.c index 95d7ecc12963..872edded1623 1

[PATCH bpf-next v4 0/2] Support eliding map lookup nullness

2024-10-02 Thread Daniel Xu
ck for when stack is uninitialized (no stack slot yet) * Updated existing tests to account for null elision * Added test case for when R2 can be both const and non-const Daniel Xu (2): bpf: verifier: Support eliding map lookup nullness bpf: selftests: verifier: Add nullness elision tests k

[PATCH bpf-next v4 1/2] bpf: verifier: Support eliding map lookup nullness

2024-10-02 Thread Daniel Xu
d in sync with these changes, as the verifier is more efficient with this change. Notable, iters.c tests had to be changed to use a map type that still requires null checks, as it's exercising verifier tracking logic w.r.t iterators. Acked-by: Eduard Zingerman Signed-off-by: Daniel Xu -

Re: [PATCH bpf-next v3 1/2] bpf: verifier: Support eliding map lookup nullness

2024-10-01 Thread Daniel Xu
On Wed, Sep 25, 2024 at 10:24:01AM GMT, Alexei Starovoitov wrote: > On Tue, Sep 24, 2024 at 12:40 PM Daniel Xu wrote: > > > > + > > +/* Returns constant key value if possible, else -1 */ > > +static long get_constant_map_key(s

Re: [PATCH bpf-next v3 1/2] bpf: verifier: Support eliding map lookup nullness

2024-10-01 Thread Daniel Xu
Hit send too early. On Tue, Oct 1, 2024, at 5:07 PM, Daniel Xu wrote: > On Wed, Sep 25, 2024 at 10:24:01AM GMT, Alexei Starovoitov wrote: >> On Tue, Sep 24, 2024 at 12:40 PM Daniel Xu wrote: >> > >> > + >> > +/* Returns constant key value if po

[PATCH bpf-next v3 2/2] bpf: selftests: verifier: Add nullness elision tests

2024-09-24 Thread Daniel Xu
d-off-by: Daniel Xu --- .../bpf/progs/verifier_array_access.c | 166 ++ 1 file changed, 166 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/verifier_array_access.c b/tools/testing/selftests/bpf/progs/verifier_array_access.c index 95d7ecc12963..2e74504ddbb5 1

[PATCH bpf-next v3 1/2] bpf: verifier: Support eliding map lookup nullness

2024-09-24 Thread Daniel Xu
d in sync with these changes, as the verifier is more efficient with this change. Notable, iters.c tests had to be changed to use a map type that still requires null checks, as it's exercising verifier tracking logic w.r.t iterators. Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c

[PATCH bpf-next v3 0/2] Support eliding map lookup nullness

2024-09-24 Thread Daniel Xu
e for when R2 can be both const and non-const Daniel Xu (2): bpf: verifier: Support eliding map lookup nullness bpf: selftests: verifier: Add nullness elision tests kernel/bpf/verifier.c | 67 ++- tools/testing/selftests/bpf/progs/iters.c | 14 +- ...

Re: [PATCH bpf-next v2 1/2] bpf: verifier: Support eliding map lookup nullness

2024-09-22 Thread Daniel Xu
On Fri, Sep 20, 2024 at 03:05:35PM GMT, Eduard Zingerman wrote: > On Sun, 2024-09-15 at 21:45 -0600, Daniel Xu wrote: > > This commit allows progs to elide a null check on statically known map > > lookup keys. In other words, if the verifier can statically prove that > >

[PATCH bpf-next v2 2/2] bpf: selftests: verifier: Add nullness elision tests

2024-09-15 Thread Daniel Xu
Test that nullness elision works for common use cases. For example, we want to check that both full and subreg stack slots are recognized. As well as when there's both const and non-const values of R2 leading up to a lookup. And obviously some bound checks. Signed-off-by: Daniel Xu --- ..

[PATCH bpf-next v2 1/2] bpf: verifier: Support eliding map lookup nullness

2024-09-15 Thread Daniel Xu
bytes. In these situations, it is desirable for the programmer to express: "this lookup should never fail, and if it does, it means I messed up the code". By omitting the null check, the programmer can "ask" the verifier to double check the logic. Signed-off-by: Daniel

[PATCH bpf-next v2 0/2] Support eliding map lookup nullness

2024-09-15 Thread Daniel Xu
k for when R2 is not a ptr to stack * Added a check for when stack is uninitialized (no stack slot yet) * Fix spinlock reg id bumping * Updated existing tests to account for null elision * Added test case for when R2 can be both const and non-const Daniel Xu (2): bpf: verifier: Support eliding

[PATCH bpf-next 2/2] bpf: selftests: verifier: Add nullness elision tests

2024-09-14 Thread Daniel Xu
Test that nullness elision works for common use cases. For example, we want to check that both full and subreg stack slots recognized. As well as multiple lookups. And obviously some bound checks. Signed-off-by: Daniel Xu --- .../bpf/progs/verifier_array_access.c | 143

[PATCH bpf-next 0/2] Support eliding map lookup nullness

2024-09-14 Thread Daniel Xu
bytes. In these situations, it is desirable for the programmer to express: "this lookup should never fail, and if it does, it means I messed up the code". By omitting the null check, the programmer can "ask" the verifier to double check the logic. Daniel Xu (2): bpf: verifier:

Re: CPUMAP latency metrics (was: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog)

2024-09-12 Thread Daniel Xu
On Thu, Sep 12, 2024, at 2:40 AM, Jesper Dangaard Brouer wrote: > On 11/09/2024 20.53, Daniel Xu wrote: >> On Wed, Sep 11, 2024 at 10:32:56AM GMT, Jesper Dangaard Brouer wrote: >>> >>> >>> On 11/09/2024 06.43, Daniel Xu wrote: >>>> [cc Jesper] &g

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-11 Thread Daniel Xu
On Wed, Sep 11, 2024 at 10:32:56AM GMT, Jesper Dangaard Brouer wrote: > > > On 11/09/2024 06.43, Daniel Xu wrote: > > [cc Jesper] > > > > On Tue, Sep 10, 2024, at 8:31 PM, Daniel Xu wrote: > > > On Tue, Sep 10, 2024 at 05:39:55PM GMT, Andrii Nakryiko wrot

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Daniel Xu
[cc Jesper] On Tue, Sep 10, 2024, at 8:31 PM, Daniel Xu wrote: > On Tue, Sep 10, 2024 at 05:39:55PM GMT, Andrii Nakryiko wrote: >> On Tue, Sep 10, 2024 at 4:44 PM Daniel Xu wrote: >> > >> > On Tue, Sep 10, 2024 at 03:21:04PM GMT, Andrii Nakryiko wrote: >> &g

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Daniel Xu
On Tue, Sep 10, 2024 at 05:39:55PM GMT, Andrii Nakryiko wrote: > On Tue, Sep 10, 2024 at 4:44 PM Daniel Xu wrote: > > > > On Tue, Sep 10, 2024 at 03:21:04PM GMT, Andrii Nakryiko wrote: > > > On Tue, Sep 10, 2024 at 3:16 PM Daniel Xu wrote: > > > > > > &g

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Daniel Xu
On Tue, Sep 10, 2024 at 03:21:04PM GMT, Andrii Nakryiko wrote: > On Tue, Sep 10, 2024 at 3:16 PM Daniel Xu wrote: > > > > > > > > On Tue, Sep 10, 2024, at 2:07 PM, Daniel Xu wrote: > > > On Tue, Sep 10, 2024 at 01:41:41PM GMT, Andrii Nakryiko wrote: > >

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Daniel Xu
On Tue, Sep 10, 2024, at 2:07 PM, Daniel Xu wrote: > On Tue, Sep 10, 2024 at 01:41:41PM GMT, Andrii Nakryiko wrote: >> On Tue, Sep 10, 2024 at 11:36 AM Alexei Starovoitov [...] > >> >> Also, Daniel, can you please make sure that dynptr we return for each >> sam

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Daniel Xu
On Tue, Sep 10, 2024 at 01:41:41PM GMT, Andrii Nakryiko wrote: > On Tue, Sep 10, 2024 at 11:36 AM Alexei Starovoitov > wrote: > > > > On Mon, Sep 9, 2024 at 5:55 PM Daniel Xu wrote: > > > > > > Right now there exists prog produce / userspace consume and us

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Daniel Xu
On Tue, Sep 10, 2024 at 11:36:36AM GMT, Alexei Starovoitov wrote: > On Mon, Sep 9, 2024 at 5:55 PM Daniel Xu wrote: > > > > Right now there exists prog produce / userspace consume and userspace > > produce / prog consume support. But it is also useful to have prog >

[PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-09 Thread Daniel Xu
use case - there is no need to involve kernel for that. Signed-off-by: Daniel Xu --- kernel/bpf/verifier.c | 6 +- tools/testing/selftests/bpf/Makefile | 3 +- .../selftests/bpf/prog_tests/ringbuf.c| 50 +++ .../bpf/progs

[PATCH bpf-next v5 06/12] bpf: Make bpf_session_cookie() kfunc return long *

2024-06-12 Thread Daniel Xu
__u64 *. You can see evidence of that intent in a3a5113393cc ("selftests/bpf: Add kprobe session cookie test"). Fix conflict by changing kfunc definition. Fixes: 5c919acef851 ("bpf: Add support for kprobe session cookie") Signed-off-by: Daniel Xu --- kernel/trace/bpf_tr

Re: [RFC bpf-next 0/1] bpf: Add page cache iterator

2021-04-08 Thread Daniel Xu
On Thu, Apr 08, 2021 at 04:13:32PM -0700, Darrick J. Wong wrote: > On Wed, Apr 07, 2021 at 02:46:10PM -0700, Daniel Xu wrote: > > There currently does not exist a way to answer the question: "What is in > > the page cache?". There are various heuristics and counters but

Re: [RFC bpf-next 1/1] bpf: Introduce iter_pagecache

2021-04-08 Thread Daniel Xu
On Thu, Apr 08, 2021 at 04:45:37PM +, Al Viro wrote: > On Wed, Apr 07, 2021 at 02:46:11PM -0700, Daniel Xu wrote: > > > +static void fini_seq_pagecache(void *priv_data) > > +{ > > + struct bpf_iter_seq_pagecache_info *info = priv_data; > > + struct radix_

Re: [RFC bpf-next 1/1] bpf: Introduce iter_pagecache

2021-04-08 Thread Daniel Xu
On Thu, Apr 08, 2021 at 10:19:35AM +0200, Christian Brauner wrote: > On Wed, Apr 07, 2021 at 02:46:11PM -0700, Daniel Xu wrote: > > This commit introduces the bpf page cache iterator. This iterator allows > > users to run a bpf prog against each page in the "page cache".

Re: [RFC bpf-next 1/1] bpf: Introduce iter_pagecache

2021-04-08 Thread Daniel Xu
On Thu, Apr 08, 2021 at 07:14:01AM +0100, Matthew Wilcox wrote: > On Wed, Apr 07, 2021 at 02:46:11PM -0700, Daniel Xu wrote: > > +struct bpf_iter_seq_pagecache_info { > > + struct mnt_namespace *ns; > > + struct radix_tree_root superblocks; > > Why are you addin

Re: [RFC bpf-next 0/1] bpf: Add page cache iterator

2021-04-08 Thread Daniel Xu
Hi Christian, thanks for taking a look. On Thu, Apr 08, 2021 at 09:51:17AM +0200, Christian Brauner wrote: > On Wed, Apr 07, 2021 at 02:46:10PM -0700, Daniel Xu wrote: > > There currently does not exist a way to answer the question: "What is in > > the page cache?". The

[RFC bpf-next 1/1] bpf: Introduce iter_pagecache

2021-04-07 Thread Daniel Xu
n the caller's mount namespace. Signed-off-by: Daniel Xu --- kernel/bpf/Makefile | 2 +- kernel/bpf/pagecache_iter.c | 293 2 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 kernel/bpf/pagecache_iter.c diff --git a/kernel/

[RFC bpf-next 0/1] bpf: Add page cache iterator

2021-04-07 Thread Daniel Xu
so that userspace can more easily tell which pages are duplicate Daniel Xu (1): bpf: Introduce iter_pagecache kernel/bpf/Makefile | 2 +- kernel/bpf/pagecache_iter.c | 293 2 files changed, 294 insertions(+), 1 deletion(-) create mode

Re: [PATCH -tip v2 00/10] kprobes: Fix stacktrace with kretprobes

2021-03-12 Thread Daniel Xu
are introduced to the series. > > Daniel, can you also test this again? I and Josh discussed a bit different > method and I've implemented it on this version. Works great, thanks! Tested-by: Daniel Xu > > This actually changes the kretprobe behavisor a bit, now the instr

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Daniel Xu
n-graph > tracer in the unwind_next_frame(). > > Signed-off-by: Masami Hiramatsu > I applied your original patchset + Josh's patch + this patch and can confirm it works for bpftrace + kretprobes. Tested-by: Daniel Xu

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-09 Thread Daniel Xu
Hi Masami, Just want to clarify a few points: On Mon, Mar 08, 2021 at 11:52:10AM +0900, Masami Hiramatsu wrote: > On Sun, 7 Mar 2021 13:23:33 -0800 > Daniel Xu wrote: > To help your understanding, let me explain. > > If we have a code here > > caller_func: > 0x00

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-07 Thread Daniel Xu
On Sat, Mar 06, 2021 at 10:13:57AM +0900, Masami Hiramatsu wrote: > On Fri, 5 Mar 2021 11:16:45 -0800 > Daniel Xu wrote: > > > Hi Masami, > > > > On Sat, Mar 06, 2021 at 12:38:57AM +0900, Masami Hiramatsu wrote: > > > Hello, > > > > > > H

Re: [PATCH] x86: kprobes: orc: Fix ORC walks in kretprobes

2021-03-05 Thread Daniel Xu
On Fri, Mar 05, 2021 at 01:32:44PM -0600, Josh Poimboeuf wrote: > On Fri, Mar 05, 2021 at 11:25:15AM -0800, Daniel Xu wrote: > > > BTW, is this a regression? or CONFIG_UNWINDER_ORC has this issue before? > > > It seems that the above commit just changed the default unwind

Re: [PATCH] x86: kprobes: orc: Fix ORC walks in kretprobes

2021-03-05 Thread Daniel Xu
On Fri, Mar 05, 2021 at 07:58:09PM +0900, Masami Hiramatsu wrote: > On Fri, 5 Mar 2021 18:28:06 +0900 > Masami Hiramatsu wrote: > > > Hi Daniel, > > > > On Thu, 4 Mar 2021 16:07:52 -0800 > > Daniel Xu wrote: > > > > > Getting a stack trace

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-05 Thread Daniel Xu
Hi Masami, On Sat, Mar 06, 2021 at 12:38:57AM +0900, Masami Hiramatsu wrote: > Hello, > > Here is a series of patches for kprobes and stacktracer to fix the kretprobe > entries in the kernel stack. This was reported by Daniel Xu. I thought that > was in the bpftrace, but it i

[PATCH] x86: kprobes: orc: Fix ORC walks in kretprobes

2021-03-04 Thread Daniel Xu
osleep+150 do_syscall_64+51 entry_SYSCALL_64_after_hwframe+68 ]: 12 Fixes: fc72ae40e303 ("x86/unwind: Make CONFIG_UNWINDER_ORC=y the default in kconfig for 64-bit") Signed-off-by: Daniel Xu --- arch/x86/kernel/unwind_orc.c | 53 +++-

Re: Broken kretprobe stack traces

2021-03-04 Thread Daniel Xu
On Wed, Mar 3, 2021, at 6:18 PM, Daniel Xu wrote: > On Wed, Mar 03, 2021 at 03:37:40PM -0500, Steven Rostedt wrote: > > On Wed, 03 Mar 2021 12:13:08 -0800 > > "Daniel Xu" wrote: > > > > > On Wed, Mar 3, 2021, at 11:58 AM, Daniel Xu wrote: > > > &

Re: Broken kretprobe stack traces

2021-03-03 Thread Daniel Xu
On Wed, Mar 03, 2021 at 03:37:40PM -0500, Steven Rostedt wrote: > On Wed, 03 Mar 2021 12:13:08 -0800 > "Daniel Xu" wrote: > > > On Wed, Mar 3, 2021, at 11:58 AM, Daniel Xu wrote: > > > On Wed, Mar 03, 2021 at 09:26:04AM -0500, Steven Rostedt wrote: > &g

Re: Broken kretprobe stack traces

2021-03-03 Thread Daniel Xu
On Wed, Mar 03, 2021 at 01:48:28PM +0900, Masami Hiramatsu wrote: > Hi Daniel, > > On Tue, 02 Mar 2021 17:15:13 -0800 > "Daniel Xu" wrote: > > > Hi Masami, > > > > Jakub reported a bug with kretprobe stack traces -- wondering if you've > &

Re: Broken kretprobe stack traces

2021-03-03 Thread Daniel Xu
On Wed, Mar 03, 2021 at 09:26:04AM -0500, Steven Rostedt wrote: > On Wed, 3 Mar 2021 13:48:28 +0900 > Masami Hiramatsu wrote: > > > > > > > > > I think (can't prove) this used to work: > > Would be good to find out if it did. I'm installing some older kernels now to check. Will report back.

Re: Broken kretprobe stack traces

2021-03-03 Thread Daniel Xu
On Wed, Mar 3, 2021, at 11:58 AM, Daniel Xu wrote: > On Wed, Mar 03, 2021 at 09:26:04AM -0500, Steven Rostedt wrote: > > On Wed, 3 Mar 2021 13:48:28 +0900 > > Masami Hiramatsu wrote: > > > > > > > > > > > > > I think (can't prove) th

Re: Why do kprobes and uprobes singlestep?

2021-03-03 Thread Daniel Xu
On Tue, Mar 02, 2021 at 06:18:23PM -0800, Alexei Starovoitov wrote: > On Tue, Mar 2, 2021 at 5:46 PM Andy Lutomirski wrote: > > > > > > > On Mar 2, 2021, at 5:22 PM, Alexei Starovoitov > > > wrote: > > > > > > On Tue, Mar 2, 2021 at 1:02 PM Andy Lutomirski > > > wrote: > > >> > > >> > >

Broken kretprobe stack traces

2021-03-03 Thread Daniel Xu
Hi Masami, Jakub reported a bug with kretprobe stack traces -- wondering if you've gotten any bug reports related to stack traces being broken for kretprobes. I think (can't prove) this used to work: # bpftrace -e 'kretprobe:__tcp_retransmit_skb { @[kstack()] = count() }' Attaching 1 pro

[PATCH bpf v7 2/2] selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL

2020-11-17 Thread Daniel Xu
gress bpf_probe_read_user_str() again. Acked-by: Song Liu Acked-by: Andrii Nakryiko Signed-off-by: Daniel Xu --- .../bpf/prog_tests/probe_read_user_str.c | 71 +++ .../bpf/progs/test_probe_read_user_str.c | 25 +++ 2 files changed, 96 insertions(+) create mode 100644 tools/testing/self

[PATCH bpf v7 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-17 Thread Daniel Xu
ernel} and probe_read_{user, kernel}_str helpers") Signed-off-by: Daniel Xu --- As mentioned in the v6 discussion, I didn't think it would make a lot of sense to put a comment in kernel/bpf/hashtab.c:alloc_htab_elem . I opted to add the comment to bpf_probe_read_user_str_common() b/c it

[PATCH bpf v7 0/2] Fix bpf_probe_read_user_str() overcopying

2020-11-17 Thread Daniel Xu
uninitialized memory v3 -> v4: * directly pass userspace pointer to prog * test more strings of different length v2 -> v3: * set pid filter before attaching prog in selftest * use long instead of int as bpf_probe_read_user_str() retval * style changes v1 -> v2: * add Fixes: tag * a

Re: [PATCH bpf v6 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-16 Thread Daniel Xu
Hi Linus, On Mon, Nov 16, 2020 at 02:15:52PM -0800, Linus Torvalds wrote: > On Mon, Nov 16, 2020 at 1:17 PM Daniel Xu wrote: > > > > Based on on-list discussion and some off-list discussion with Alexei, > > I'd like to propose the v4-style patch without the `(*out &

[PATCH bpf v6 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-16 Thread Daniel Xu
ernel} and probe_read_{user, kernel}_str helpers") Signed-off-by: Daniel Xu --- Based on on-list discussion and some off-list discussion with Alexei, I'd like to propose the v4-style patch without the `(*out & ~mask)` bit. We can't really zero out the rest of the buffer due to

[PATCH bpf v6 0/2] Fix bpf_probe_read_user_str() overcopying

2020-11-16 Thread Daniel Xu
> v4: * directly pass userspace pointer to prog * test more strings of different length v2 -> v3: * set pid filter before attaching prog in selftest * use long instead of int as bpf_probe_read_user_str() retval * style changes v1 -> v2: * add Fixes: tag * add selftest Daniel Xu (2): lib/strnc

[PATCH bpf v6 2/2] selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL

2020-11-16 Thread Daniel Xu
gress bpf_probe_read_user_str() again. Acked-by: Song Liu Acked-by: Andrii Nakryiko Signed-off-by: Daniel Xu --- .../bpf/prog_tests/probe_read_user_str.c | 71 +++ .../bpf/progs/test_probe_read_user_str.c | 25 +++ 2 files changed, 96 insertions(+) create mode 100644 tools/testing/self

Re: [PATCH bpf v5 0/2] Fix bpf_probe_read_user_str() overcopying

2020-11-12 Thread Daniel Xu
On Wed Nov 11, 2020 at 3:22 PM PST, Andrii Nakryiko wrote: > On Wed, Nov 11, 2020 at 2:46 PM Daniel Xu wrote: > > > > 6ae08ae3dea2 ("bpf: Add probe_read_{user, kernel} and probe_read_{user, > > kernel}_str helpers") introduced a subtle bug where > > bpf_pr

[PATCH bpf v5 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-11 Thread Daniel Xu
{user, kernel} and probe_read_{user, kernel}_str helpers") Signed-off-by: Daniel Xu --- lib/strncpy_from_user.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index e6d5fcc2cdf3..83180742e729 100644

Re: [selftest/bpf] b83590ee1a: BUG:KASAN:slab-out-of-bounds_in_l

2020-11-11 Thread Daniel Xu
bae607b0524632b7793 ("[PATCH bpf v3 2/2] > > selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after > > NUL") > > url: > > https://github.com/0day-ci/linux/commits/Daniel-Xu/Fix-bpf_probe_read_user_str-overcopying/20201106-033210 > > base: https

[PATCH bpf v5 0/2] Fix bpf_probe_read_user_str() overcopying

2020-11-11 Thread Daniel Xu
s of different length v2 -> v3: * set pid filter before attaching prog in selftest * use long instead of int as bpf_probe_read_user_str() retval * style changes v1 -> v2: * add Fixes: tag * add selftest Daniel Xu (2): lib/strncpy_from_user.c: Don't overcopy bytes after NUL

[PATCH bpf v5 2/2] selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL

2020-11-11 Thread Daniel Xu
gress bpf_probe_read_user_str() again. Acked-by: Song Liu Acked-by: Andrii Nakryiko Signed-off-by: Daniel Xu --- .../bpf/prog_tests/probe_read_user_str.c | 71 +++ .../bpf/progs/test_probe_read_user_str.c | 25 +++ 2 files changed, 96 insertions(+) create mode 100644 tools/testing/self

Re: [lib/strncpy_from_user.c] 00a4ef91e8: BUG:KASAN:slab-out-of-bounds_in_s

2020-11-06 Thread Daniel Xu
om_user.c: Don't overcopy bytes after NUL terminator") > > url: > > https://github.com/0day-ci/linux/commits/Daniel-Xu/lib-strncpy_from_user-c-Don-t-overcopy-bytes-after-NUL-terminator/20201104-103306 > > base: https://git.kernel.org/cgit/linux/kernel/git/bpf/bpf-next.git mast

[PATCH bpf v4 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-05 Thread Daniel Xu
ernel} and probe_read_{user, kernel}_str helpers") Signed-off-by: Daniel Xu --- lib/strncpy_from_user.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index e6d5fcc2cdf3..82a67dde136b 100644 --- a/lib/strncpy_f

  1   2   >