[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

[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

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 >

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 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 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 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
[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-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: 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

[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:

[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 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 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 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 --- ..

[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

[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/

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

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 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 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 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: 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: > > > &

[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: [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

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] 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

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

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: > > >> > > >> > >

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: 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 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 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

[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

[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

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-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 -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 v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-22 Thread Daniel Xu
On Thu Aug 22, 2019 at 11:05 AM Peter Zijlstra wrote: > On Thu, Aug 22, 2019 at 07:54:16AM +, Song Liu wrote: > > Hi Peter, > > > > > On Aug 22, 2019, at 12:47 AM, Peter Zijlstra wrote: > > > > > > On Wed, Aug 21, 2019 at 06:43:49PM +, Yonghong Song wrote: > > >> On 8/21/19 11:31 AM, Pe

[PATCH v3 bpf-next 2/4] libbpf: Add helpers to extract perf fd from bpf_link

2019-08-16 Thread Daniel Xu
es it clear to users what they can expect to extract from what type of link. Acked-by: Song Liu Signed-off-by: Daniel Xu --- tools/lib/bpf/libbpf.c | 21 + tools/lib/bpf/libbpf.h | 13 + tools/lib/bpf/libbpf.map | 4 3 files changed, 38 insertions(+) diff --

[PATCH v3 bpf-next 0/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE

2019-08-16 Thread Daniel Xu
2: - More descriptive cover letter - Make API more generic and support uprobes as well - Use casters/getters for libbpf instead of single getter - Fix typos - Remove size field from ioctl struct - Split out libbpf.h sync to tools dir to separate commit Daniel Xu (4): tracing/probe: Add PERF_EVENT_

[PATCH v3 bpf-next 4/4] tracing/probe: Add self test for PERF_EVENT_IOC_QUERY_PROBE

2019-08-16 Thread Daniel Xu
Acked-by: Andrii Nakryiko Signed-off-by: Daniel Xu --- .../selftests/bpf/prog_tests/attach_probe.c | 106 ++ 1 file changed, 106 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c index

[PATCH v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-16 Thread Daniel Xu
for [uk]probes but leave the possibility open for other probes like tracepoint. Signed-off-by: Daniel Xu --- include/linux/trace_events.h| 12 include/uapi/linux/perf_event.h | 23 +++ kernel/events/core.c| 20 kernel/trace

[PATCH v3 bpf-next 3/4] tracing/probe: Sync perf_event.h to tools

2019-08-16 Thread Daniel Xu
Signed-off-by: Daniel Xu --- tools/include/uapi/linux/perf_event.h | 23 +++ 1 file changed, 23 insertions(+) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index 7198ddd0c6b1..8783d29a807a 100644 --- a/tools/include/uapi/linux

[PATCH bpf-next 0/5] Add PERF_FORMAT_LOST read_format

2019-09-17 Thread Daniel Xu
s possible I missed something while reading the code so please let me know if I am mistaken. Daniel Xu (5): perf/core: Add PERF_FORMAT_LOST read_format perf/core: Sync perf_event.h to tools libbpf: Add helpers to extract perf fd from bpf_link libbpf: Set read_format PERF_FORMAT_LOST on kpr

[PATCH bpf-next 1/5] perf/core: Add PERF_FORMAT_LOST read_format

2019-09-17 Thread Daniel Xu
he underlying kprobe infrastructure and misses from ringbuffer infrastructure. Signed-off-by: Daniel Xu --- include/linux/trace_events.h| 1 + include/uapi/linux/perf_event.h | 5 - kernel/events/core.c| 39 ++--- kernel/trace/trace_kprobe.c | 8

[PATCH bpf-next 3/5] libbpf: Add helpers to extract perf fd from bpf_link

2019-09-17 Thread Daniel Xu
clear to users what they can expect to extract from what type of link. Acked-by: Song Liu Acked-by: Andrii Nakryiko Signed-off-by: Daniel Xu --- tools/lib/bpf/libbpf.c | 21 + tools/lib/bpf/libbpf.h | 13 + tools/lib/bpf/libbpf.map | 3 +++ 3 files changed

[PATCH bpf-next 5/5] libbpf: Add selftest for PERF_FORMAT_LOST perf read_format

2019-09-17 Thread Daniel Xu
Signed-off-by: Daniel Xu --- .../selftests/bpf/prog_tests/attach_probe.c | 32 ++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c index 5ecc267d98b0

[PATCH bpf-next 4/5] libbpf: Set read_format PERF_FORMAT_LOST on kprobe perf fds

2019-09-17 Thread Daniel Xu
There is no way to get the nmissed count from kprobes that are created using the perf API. The previous commits added read_format support for this count. Enable it in this commit. Signed-off-by: Daniel Xu --- tools/lib/bpf/libbpf.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions

[PATCH bpf-next 2/5] perf/core: Sync perf_event.h to tools

2019-09-17 Thread Daniel Xu
Signed-off-by: Daniel Xu --- tools/include/uapi/linux/perf_event.h | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index 7198ddd0c6b1..bd874c7257f0 100644 --- a/tools/include/uapi/linux

Re: [PATCH bpf-next 1/5] perf/core: Add PERF_FORMAT_LOST read_format

2019-09-17 Thread Daniel Xu
On Tue Sep 17, 2019 at 10:32 PM kbuild test robot wrote: > All errors (new ones prefixed by >>): > >kernel/events/core.c: In function 'perf_event_lost': > >> kernel/events/core.c:4753:11: error: implicit declaration of function > >> 'perf_kprobe_missed'; did you mean 'perf_release'? > >> [-W

Re: [PATCH bpf-next 1/5] perf/core: Add PERF_FORMAT_LOST read_format

2019-09-27 Thread Daniel Xu
Hi Jiri, On Tue Sep 24, 2019 at 10:33 AM Jiri Olsa wrote: > On Tue, Sep 17, 2019 at 06:30:52AM -0700, Daniel Xu wrote: > > SNIP > > > + PERF_FORMAT_MAX = 1U << 5, /* non-ABI */ > > }; > > > > #define PERF_ATTR_SIZE_VER064

Re: [PATCH v3 bpf-next 2/4] libbpf: Add helpers to extract perf fd from bpf_link

2019-08-19 Thread Daniel Xu
On Mon, Aug 19, 2019, at 10:45 AM, Andrii Nakryiko wrote: > On Fri, Aug 16, 2019 at 3:32 PM Daniel Xu wrote: > > > > It is sometimes necessary to perform ioctl's on the underlying perf fd. > > There is not currently a way to extract the fd given a bpf_link, so add a

Re: [PATCH v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-19 Thread Daniel Xu
On Mon Aug 19, 2019 at 6:26 PM Alexei Starovoitov wrote: > On Fri, Aug 16, 2019 at 3:33 PM Daniel Xu wrote: > > > > It's useful to know [uk]probe's nmissed and nhit stats. For example with > > tracing tools, it's important to know when events may have been l

Re: [PATCH v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-20 Thread Daniel Xu
Hi Peter, On Tue Aug 20, 2019 at 4:45 PM Peter Zijlstra wrote: > On Fri, Aug 16, 2019 at 03:31:46PM -0700, Daniel Xu wrote: > > It's useful to know [uk]probe's nmissed and nhit stats. For example with > > tracing tools, it's important to know when events may have be

[PATCH v4 bpf-next 0/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE

2019-08-20 Thread Daniel Xu
ve size field from ioctl struct - Split out libbpf.h sync to tools dir to separate commit Daniel Xu (4): tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl libbpf: Add helpers to extract perf fd from bpf_link tracing/probe: Sync perf_event.h to tools tracing/probe: Add self test for PE

[PATCH v4 bpf-next 4/4] tracing/probe: Add self test for PERF_EVENT_IOC_QUERY_PROBE

2019-08-20 Thread Daniel Xu
Acked-by: Andrii Nakryiko Signed-off-by: Daniel Xu --- .../selftests/bpf/prog_tests/attach_probe.c | 115 ++ 1 file changed, 115 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c index

[PATCH v4 bpf-next 3/4] tracing/probe: Sync perf_event.h to tools

2019-08-20 Thread Daniel Xu
Signed-off-by: Daniel Xu --- tools/include/uapi/linux/perf_event.h | 23 +++ 1 file changed, 23 insertions(+) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index 7198ddd0c6b1..8783d29a807a 100644 --- a/tools/include/uapi/linux

[PATCH v4 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-20 Thread Daniel Xu
for [uk]probes but leave the possibility open for other probes like tracepoint. Signed-off-by: Daniel Xu --- include/linux/trace_events.h| 2 ++ include/uapi/linux/perf_event.h | 23 +++ kernel/events/core.c| 20 kernel/trace/trace_kp

[PATCH v4 bpf-next 2/4] libbpf: Add helpers to extract perf fd from bpf_link

2019-08-20 Thread Daniel Xu
es it clear to users what they can expect to extract from what type of link. Acked-by: Song Liu Acked-by: Andrii Nakryiko Signed-off-by: Daniel Xu --- tools/lib/bpf/libbpf.c | 21 + tools/lib/bpf/libbpf.h | 13 + tools/lib/bpf/libbpf.map | 3 +++ 3 files change

Re: [PATCH v2 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-12 Thread Daniel Xu
On Mon, Aug 12, 2019, at 8:57 AM, Andrii Nakryiko wrote: > On Fri, Aug 9, 2019 at 2:47 PM Daniel Xu wrote: > > > > It's useful to know [uk]probe's nmissed and nhit stats. For example with > > tracing tools, it's important to know when events may have been l

Re: [PATCH v2 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-13 Thread Daniel Xu
On Tue, Aug 13, 2019, at 2:47 PM, Song Liu wrote: > On Fri, Aug 9, 2019 at 2:48 PM Daniel Xu wrote: > > > > It's useful to know [uk]probe's nmissed and nhit stats. For example with > > tracing tools, it's important to know when events may have been lost. >

[PATCH v2 bpf-next 2/4] libbpf: Add helpers to extract perf fd from bpf_link

2019-08-09 Thread Daniel Xu
es it clear to users what they can expect to extract from what type of link. Signed-off-by: Daniel Xu --- tools/lib/bpf/libbpf.c | 19 +++ tools/lib/bpf/libbpf.h | 8 tools/lib/bpf/libbpf.map | 6 ++ 3 files changed, 33 insertions(+) diff --git a/tools/lib/bpf/libbp

[PATCH v2 bpf-next 0/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE

2019-08-09 Thread Daniel Xu
t libbpf.h sync to tools dir to separate commit Daniel Xu (4): tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl libbpf: Add helpers to extract perf fd from bpf_link tracing/probe: Sync perf_event.h to tools tracing/probe: Add self test for PERF_EVENT_IOC_QUERY_PROBE include/li

[PATCH v2 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl

2019-08-09 Thread Daniel Xu
for [uk]probes but leave the possibility open for other probes like tracepoint. Signed-off-by: Daniel Xu --- include/linux/trace_events.h| 12 include/uapi/linux/perf_event.h | 19 +++ kernel/events/core.c| 20 kernel/trace

[PATCH v2 bpf-next 3/4] tracing/probe: Sync perf_event.h to tools

2019-08-09 Thread Daniel Xu
Signed-off-by: Daniel Xu --- tools/include/uapi/linux/perf_event.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index 7198ddd0c6b1..65faa9b2a3b4 100644 --- a/tools/include/uapi/linux

[PATCH v2 bpf-next 4/4] tracing/probe: Add self test for PERF_EVENT_IOC_QUERY_PROBE

2019-08-09 Thread Daniel Xu
Signed-off-by: Daniel Xu --- .../selftests/bpf/prog_tests/attach_probe.c | 102 ++ 1 file changed, 102 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c index 5ecc267d98b0..bb53103ddb66

Re: [PATCH v2 bpf-next 0/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE

2019-08-09 Thread Daniel Xu
On Fri, Aug 9, 2019, at 2:47 PM, Daniel Xu wrote: > It's useful to know [uk]probe's nmissed and nhit stats. For example with > tracing tools, it's important to know when events may have been lost. > debugfs currently exposes a control file to get this information, but >

[PATCH bpf-next] libbpf: Export bpf_object__load_vmlinux_btf

2020-05-26 Thread Daniel Xu
perviously no way to load BTF on-demand. This commit exports the bpf_object__load_vmlinux_btf such that we are able to load BTF on demand. Signed-off-by: Daniel Xu --- tools/lib/bpf/libbpf.c | 2 +- tools/lib/bpf/libbpf.h | 1 + tools/lib/bpf/libbpf.map | 1 + 3 files changed, 3 insertions(+), 1

Re: [PATCH bpf-next] libbpf: Export bpf_object__load_vmlinux_btf

2020-05-27 Thread Daniel Xu
Hi Andrii, On Tue May 26, 2020 at 3:09 PM PST, Andrii Nakryiko wrote: > On Tue, May 26, 2020 at 7:09 PM Daniel Xu wrote: > > > > Right now the libbpf model encourages loading the entire object at once. > > In this model, libbpf handles loading BTF from vmlinux for us. H

[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: [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 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 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-next] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-03 Thread Daniel Xu
bytes after the NUL terminator, it can result in seemingly identical strings occupying multiple slots in a BPF map. This behavior is subtle and totally unexpected by the user. This commit uses the proper word-at-a-time APIs to avoid overcopying. Signed-off-by: Daniel Xu --- lib/strncpy_from_user.c

Re: [PATCH bpf-next] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-04 Thread Daniel Xu
Hi Daniel, On Wed Nov 4, 2020 at 8:24 AM PST, Daniel Borkmann wrote: > On 11/4/20 3:29 AM, Daniel Xu wrote: > > do_strncpy_from_user() may copy some extra bytes after the NUL > > terminator into the destination buffer. This usually does not matter for > > normal string oper

Re: [PATCH bpf-next] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-04 Thread Daniel Xu
On Wed Nov 4, 2020 at 2:36 PM PST, Daniel Borkmann wrote: > On 11/4/20 9:18 PM, Daniel Xu wrote: > > On Wed Nov 4, 2020 at 8:24 AM PST, Daniel Borkmann wrote: > >> On 11/4/20 3:29 AM, Daniel Xu wrote: > >>> do_strncpy_from_user() may copy some extra bytes after the

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

2020-11-04 Thread Daniel Xu
gress bpf_probe_read_user_str() again. Signed-off-by: Daniel Xu --- .../bpf/prog_tests/probe_read_user_str.c | 60 +++ .../bpf/progs/test_probe_read_user_str.c | 34 +++ 2 files changed, 94 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/probe_read_user_

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

2020-11-04 Thread Daniel Xu
p keys, as seemingly identical strings can occupy multiple entries in a map. This patchset fixes the issue and introduces a selftest to prevent future regressions. Daniel Xu (2): lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator selftest/bpf: Test bpf_probe_read_user_str()

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

2020-11-04 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..d084189eb05c 100644 --- a/lib/strncpy_f

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

2020-11-05 Thread Daniel Xu
On Thu Nov 5, 2020 at 10:16 AM PST, Song Liu wrote: > > > > On Nov 4, 2020, at 6:25 PM, Daniel Xu wrote: > > > > do_strncpy_from_user() may copy some extra bytes after the NUL > > We have multiple use of "NUL" here, should be "NULL"? > >

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

2020-11-05 Thread Daniel Xu
On Thu Nov 5, 2020 at 10:30 AM PST, Song Liu wrote: > > > > On Nov 4, 2020, at 6:25 PM, Daniel Xu wrote: > > > > Previously, bpf_probe_read_user_str() could potentially overcopy the > > trailing bytes after the NUL due to how do_strncpy_from_user() does the >

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

2020-11-05 Thread Daniel Xu
gress bpf_probe_read_user_str() again. Signed-off-by: Daniel Xu --- .../bpf/prog_tests/probe_read_user_str.c | 60 +++ .../bpf/progs/test_probe_read_user_str.c | 34 +++ 2 files changed, 94 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/probe_read_user_

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

2020-11-05 Thread Daniel Xu
ges v1 -> v2: * add Fixes: tag * add selftest Daniel Xu (2): lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL lib/strncpy_from_user.c | 9 ++- .../bpf/prog_tests/

[PATCH bpf v3 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

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

2020-11-05 Thread Daniel Xu
On Thu Nov 5, 2020 at 1:32 PM PST, Andrii Nakryiko wrote: > On Wed, Nov 4, 2020 at 8:51 PM Daniel Xu wrote: [...] > > diff --git a/tools/testing/selftests/bpf/progs/test_probe_read_user_str.c > > b/tools/testing/selftests/bpf/progs/test_probe_read_user_str.c > > new file

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

2020-11-05 Thread Daniel Xu
On Thu Nov 5, 2020 at 3:31 PM PST, Song Liu wrote: > > > > On Nov 5, 2020, at 3:22 PM, Daniel Xu wrote: > > > > On Thu Nov 5, 2020 at 1:32 PM PST, Andrii Nakryiko wrote: > >> On Wed, Nov 4, 2020 at 8:51 PM Daniel Xu wrote: > > [...] > >>

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

2020-11-05 Thread Daniel Xu
gress bpf_probe_read_user_str() again. 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/selftests/bpf/prog_tests/probe_read_user_str.c c

[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

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

2020-11-05 Thread Daniel Xu
ttaching 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 terminator selftest/bpf: Test bpf_probe_read_user_str() strips trailing b

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

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

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

  1   2   >