Re: [PATCH v4 1/1] libbpf: fix USDT SIB argument handling causing unrecognized register error

2025-08-01 Thread Alexei Starovoitov
On Fri, Aug 1, 2025 at 9:16 AM Jiawei Zhao wrote: > > From: Jiawei Zhao > > On x86-64, USDT arguments can be specified using Scale-Index-Base (SIB) > addressing, e.g. "1@-96(%rbp,%rax,8)". The current USDT implementation > in libbpf cannot parse this format, causing `bpf_program__attach_usdt()` >

Re: [PATCH bpf-next v3] selftests/bpf: Add LPM trie microbenchmarks

2025-07-31 Thread Alexei Starovoitov
On Tue, Jul 29, 2025 at 6:56 AM Matt Fleming wrote: > > On Mon, Jul 28, 2025 at 3:35 PM Alexei Starovoitov > wrote: > > > > Please make a full description of what the test does, > > since it's not trivial to decipher from the code. > > If I'm reading it

Re: [PATCH bpf-next v3] selftests/bpf: Add LPM trie microbenchmarks

2025-07-28 Thread Alexei Starovoitov
On Tue, Jul 22, 2025 at 9:02 AM Matt Fleming wrote: > > From: Matt Fleming > > Add benchmarks for the standard set of operations: lookup, update, > delete. Also, include a benchmark for trie_free() which is known to have > terrible performance for maps with many entries. > > Benchmarks operate on

Re: [PATCH bpf-next v5 1/3] btf: allow mmap of vmlinux btf

2025-07-17 Thread Alexei Starovoitov
On Thu, Jul 17, 2025 at 8:15 AM Lorenz Bauer wrote: > > On Thu, Jul 17, 2025 at 3:49 PM Alexei Starovoitov > wrote: > > > __pa_symbol() should work for start_BTF, but would be good > > to double check with Ard that the rest stays linear. > > Alexei, > > This

Re: [PATCH bpf-next v5 1/3] btf: allow mmap of vmlinux btf

2025-07-17 Thread Alexei Starovoitov
On Thu, Jul 17, 2025 at 6:18 AM Lorenz Bauer wrote: > > Hi Breno, > > Thanks for reaching out. > > On Thu, Jul 17, 2025 at 1:39 PM Breno Leitao wrote: > > > Should __pa_symbol() be used instead of virt_to_phys()? > > I'm not really well versed with mm in general. Looking around a bit I > found so

Re: [PATCH bpf-next v2 3/3] selftests/bpf: Add selftest for attaching tracing programs to functions in deny list

2025-07-16 Thread Alexei Starovoitov
On Mon, Jul 14, 2025 at 5:04 AM KaFai Wan wrote: > > The reuslt: > > $ tools/testing/selftests/bpf/test_progs --name=tracing_deny > #467/1 tracing_deny/migrate_disable:OK > #467 tracing_deny:OK > Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED > > Signed-off-by: KaFai Wan > --- > .../self

Re: [PATCH 1/2] bpf, arm64: remove structs on stack constraint

2025-07-15 Thread Alexei Starovoitov
On Tue, Jul 15, 2025 at 7:31 AM Will Deacon wrote: > > On Tue, Jul 15, 2025 at 04:02:25PM +0200, Alexis Lothoré wrote: > > On Tue Jul 15, 2025 at 3:32 PM CEST, Will Deacon wrote: > > > On Wed, Jul 09, 2025 at 10:36:55AM +0200, Alexis Lothoré (eBPF > > > Foundation) wrote: > > >> While introducing

Re: [PATCH bpf-next 2/3] bpf: Show precise rejected function when attaching to __btf_id functions

2025-07-10 Thread Alexei Starovoitov
On Thu, Jul 10, 2025 at 9:27 AM KaFai Wan wrote: > > Show the precise rejected function name when attaching tracing to > __btf_id functions. > > $ ./fentry > libbpf: prog 'migrate_disable': BPF program load failed: -EINVAL > libbpf: prog 'migrate_disable': -- BEGIN PROG LOAD LOG -- > Attaching tra

Re: [PATCH v3 2/2] selftests/bpf: Add testcases for BPF_ADD and BPF_SUB

2025-06-24 Thread Alexei Starovoitov
On Tue, Jun 24, 2025 at 3:45 PM Eduard Zingerman wrote: > > On Mon, 2025-06-23 at 00:03 -0400, Harishankar Vishwanathan wrote: > > The previous commit improves the precision in scalar(32)_min_max_add, > > and scalar(32)_min_max_sub. The improvement in precision occurs in cases > > when all outcome

Re: [PATCH bpf 2/7] bpf/x86: prevent trampoline attachment when args location on stack is uncertain

2025-06-15 Thread Alexei Starovoitov
On Sun, Jun 15, 2025 at 7:00 AM Alexis Lothoré wrote: > > On Sat Jun 14, 2025 at 12:35 AM CEST, Alexei Starovoitov wrote: > > On Fri, Jun 13, 2025 at 1:59 AM Alexis Lothoré > > wrote: > >> > >> On Fri Jun 13, 2025 at 10:32 AM CEST, Peter Zijlstra wrote: >

Re: [PATCH bpf 2/7] bpf/x86: prevent trampoline attachment when args location on stack is uncertain

2025-06-13 Thread Alexei Starovoitov
On Fri, Jun 13, 2025 at 1:59 AM Alexis Lothoré wrote: > > On Fri Jun 13, 2025 at 10:32 AM CEST, Peter Zijlstra wrote: > > On Fri, Jun 13, 2025 at 10:26:37AM +0200, Alexis Lothoré wrote: > >> Hi Peter, > >> > >> On Fri Jun 13, 2025 at 10:11 AM CEST, Peter Zijlstra wrote: > >> > On Fri, Jun 13, 2025

Re: [PATCH] selftests/bpf: fix signedness bug in redir_partial()

2025-06-11 Thread Alexei Starovoitov
On Sun, Jun 8, 2025 at 7:38 AM wangfushuai wrote: > > When xsend() returns -1 (error), the check 'n < sizeof(buf)' incorrectly > treats it as success due to unsigned promotion. Explicitly check for -1 > first. > > Fixes: a4b7193d8efd ("selftests/bpf: Add sockmap test for redirecting partial > skb

Re: [PATCH bpf-next v4 9/9] bpf: Fall back to nospec for sanitization-failures

2025-06-10 Thread Alexei Starovoitov
On Tue, Jun 3, 2025 at 2:32 PM Luis Gerhorst wrote: > > ALU sanitization was introduced to ensure that a subsequent ptr access > can never go OOB, even under speculation. This is required because we > currently allow speculative scalar confusion. Spec. scalar confusion is > possible because Spectr

Re: [PATCH v2] selftests/bpf: Validate UDP length in cls_redirect test

2025-06-06 Thread Alexei Starovoitov
On Mon, Jun 2, 2025 at 10:28 PM Suchit Karunakaran wrote: > > From: Suchit > > Add validation step to ensure that the UDP payload is > long enough to contain the expected GUE and UNIGUE encapsulation > headers > > Signed-off-by: Suchit > --- > > Changes since v2: > - Rebase > > tools/testing/se

Re: [Question] attributes encoding in BTF

2025-06-06 Thread Alexei Starovoitov
On Fri, Jun 6, 2025 at 12:45 AM Alexis Lothoré wrote: > > Hi Alexei, > > On Thu Jun 5, 2025 at 6:09 PM CEST, Alexei Starovoitov wrote: > > On Thu, Jun 5, 2025 at 12:35 AM Alexis Lothoré > > wrote: > >> > >> Hi Ihor, > >> > >> On Wed Jun

Re: [Question] attributes encoding in BTF

2025-06-05 Thread Alexei Starovoitov
On Thu, Jun 5, 2025 at 12:35 AM Alexis Lothoré wrote: > > Hi Ihor, > > On Wed Jun 4, 2025 at 7:31 PM CEST, Ihor Solodrai wrote: > > On 6/4/25 2:02 AM, Alexis Lothoré wrote: > > [...] > > >> Could I be missing something obvious ? Or did I misunderstand the actual > >> attribute encoding feature ?

Re: [RESEND PATCH] selftests/bpf: Fix bpf selftest build error

2025-06-03 Thread Alexei Starovoitov
On Tue, Jun 3, 2025 at 10:33 AM T.J. Mercier wrote: > > On Mon, May 12, 2025 at 2:12 AM Saket Kumar Bhaskar > wrote: > > > > On linux-next, build for bpf selftest displays an error due to > > mismatch in the expected function signature of bpf_testmod_test_read > > and bpf_testmod_test_write. > >

Re: [PATCH] libbpf: add support for printing BTF character arrays as strings

2025-06-02 Thread Alexei Starovoitov
On Mon, Jun 2, 2025 at 8:05 AM Ian Rogers wrote: > > On Sat, May 31, 2025 at 11:20 AM Alexei Starovoitov > wrote: > > > > On Sat, May 31, 2025 at 12:20 AM Blake Jones wrote: > > > > > > The BTF dumper code currently displays arrays of characters as just t

Re: [PATCH] libbpf: add support for printing BTF character arrays as strings

2025-05-31 Thread Alexei Starovoitov
On Sat, May 31, 2025 at 12:20 AM Blake Jones wrote: > > The BTF dumper code currently displays arrays of characters as just that - > arrays, with each character formatted individually. Sometimes this is what > makes sense, but it's nice to be able to treat that array as a string. > > This change a

Re: [PATCH bpf-next v1 1/2] bpf: Restrict usage scope of bpf_get_cgroup_classid

2025-05-29 Thread Alexei Starovoitov
On Wed, May 28, 2025 at 9:17 AM Jiayuan Chen wrote: > > A previous commit expanded the usage scope of bpf_get_cgroup_classid() to > all contexts (see Fixes tag), but this was inappropriate. > > First, syzkaller reported a bug [1]. > Second, it uses skb as an argument, but its implementation varies

Re: [PATCH bpf-next 1/2] bpf: Add bpf_task_cwd_from_pid() kfunc

2025-05-28 Thread Alexei Starovoitov
On Wed, May 28, 2025 at 8:37 PM Rong Tao wrote: > > From: Rong Tao > > It is a bit troublesome to get cwd based on pid in bpf program, such as > bpftrace example [1]. > > This patch therefore adds a new bpf_task_cwd_from_pid() kfunc which > allows BPF programs to get cwd from a pid. > > [1] https

Re: vmlinux BTF as a module (was Re: [PATCH bpf-next v4 0/3] Allow mmap of /sys/kernel/btf/vmlinux)

2025-05-22 Thread Alexei Starovoitov
On Wed, May 21, 2025 at 8:00 AM Alan Maguire wrote: > > > Hi Alan, > > > > Thanks for taking a look at this. I've been following your related effort > > to allow /sys/kernel/btf/vmlinux as a module in support of small systems > > with kernel-size constraints, and wondered how this series might aff

Re: [RESEND PATCH] selftests/bpf: Fix bpf selftest build warning

2025-05-12 Thread Alexei Starovoitov
On Mon, May 12, 2025 at 2:23 AM Greg KH wrote: > > On Mon, May 12, 2025 at 02:45:11PM +0530, Saket Kumar Bhaskar wrote: > > On linux-next, build for bpf selftest displays a warning: > > > > Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' > > differs from latest version at 'includ

Re: [PATCH bpf-next v3 00/11] bpf: Mitigate Spectre v1 using barriers

2025-05-09 Thread Alexei Starovoitov
On Fri, May 9, 2025 at 11:39 AM wrote: > > Hello: > > This series was applied to bpf/bpf-next.git (master) > by Alexei Starovoitov : > > On Thu, 1 May 2025 09:35:51 +0200 you wrote: > > This improves the expressiveness of unprivileged BPF by inserting > >

Re: [PATCH] selftests/bpf: Fix bpf selftest build error

2025-05-09 Thread Alexei Starovoitov
On Fri, May 9, 2025 at 5:24 AM Saket Kumar Bhaskar wrote: > > On linux-next, build for bpf selftest displays an error due to > mismatch in the expected function signature of bpf_testmod_test_read > and bpf_testmod_test_write. > > Commit 97d06802d10a ("sysfs: constify bin_attribute argument of > b

Re: [PATCH bpf-next v2 1/3] btf: allow mmap of vmlinux btf

2025-05-05 Thread Alexei Starovoitov
On Mon, May 5, 2025 at 7:37 AM Lorenz Bauer wrote: > > On Fri, May 2, 2025 at 6:15 PM Alexei Starovoitov > wrote: > > remap_pfn_range() should be avoided. > > See big comment in kernel/events/core.c in map_range(). > > > > The following seems to work: > &g

Re: [PATCH bpf-next v2 1/3] btf: allow mmap of vmlinux btf

2025-05-02 Thread Alexei Starovoitov
On Fri, May 2, 2025 at 3:20 AM Lorenz Bauer wrote: > > User space needs access to kernel BTF for many modern features of BPF. > Right now each process needs to read the BTF blob either in pieces or > as a whole. Allow mmaping the sysfs file so that processes can directly > access the memory alloca

Re: [PATCH bpf-next 1/2] btf: allow mmap of vmlinux btf

2025-05-01 Thread Alexei Starovoitov
On Thu, May 1, 2025 at 7:28 AM Lorenz Bauer wrote: > > User space needs access to kernel BTF for many modern features of BPF. > Right now each process needs to read the BTF blob either in pieces or > as a whole. Allow mmaping the sysfs file so that processes can directly > access the memory alloca

Re: [PATCH RFC bpf-next 1/4] bpf: add struct largest member size in func model

2025-04-24 Thread Alexei Starovoitov
On Thu, Apr 24, 2025 at 6:38 AM Alexis Lothoré wrote: > > Hi Xu, > > On Thu Apr 24, 2025 at 2:00 PM CEST, Xu Kuohai wrote: > > On 4/24/2025 3:24 AM, Alexis Lothoré wrote: > >> Hi Andrii, > >> > >> On Wed Apr 23, 2025 at 7:15 PM CEST, Andrii Nakryiko wrote: > >>> On Thu, Apr 17, 2025 at 12:14 AM Al

Re: [PATCH bpf-next v3 1/2] bpf: Allow access to const void pointer arguments in tracing programs

2025-04-22 Thread Alexei Starovoitov
On Thu, Apr 17, 2025 at 8:16 AM KaFai Wan wrote: > > Adding support to access arguments with const void pointer arguments > in tracing programs. > > Currently we allow tracing programs to access void pointers. If we try to > access argument which is pointer to const void like 2nd argument in kfree

Re: [PATCH bpf-next v4 2/3] bpf, sockmap: avoid using sk_socket after free when reading

2025-04-09 Thread Alexei Starovoitov
On Tue, Apr 8, 2025 at 12:31 AM Jiayuan Chen wrote: > > There are potential concurrency issues, as shown below. > ''' > CPU0 CPU1 > sk_psock_verdict_data_ready: > socket *sock = sk->sk_socket > if (!sock) return >close(fd): >

Re: [PATCH RESEND bpf-next v2] selftests/bpf: close the file descriptor to avoid resource leaks

2025-04-09 Thread Alexei Starovoitov
On Wed, Apr 9, 2025 at 4:28 PM Andrii Nakryiko wrote: > > On Tue, Apr 8, 2025 at 11:33 AM Malaya Kumar Rout > wrote: > > > > Static Analyis for bench_htab_mem.c with cppcheck:error > > typo: analysis (lower case and typo) > > you can also make into a bit more human-readable sentence: > > "Static

Re: [PATCH bpf v2 1/2] bpf, xdp: clean head/meta when expanding it

2025-04-03 Thread Alexei Starovoitov
On Thu, Apr 3, 2025 at 5:27 PM Jiayuan Chen wrote: > > April 3, 2025 at 22:24, "Alexei Starovoitov" > wrote: > > > > > > > On Sun, Mar 30, 2025 at 8:27 PM Jiayuan Chen wrote: > > > > > > > > The device allocates an skb, it add

Re: [PATCH bpf v2 1/2] bpf, xdp: clean head/meta when expanding it

2025-04-03 Thread Alexei Starovoitov
On Thu, Apr 3, 2025 at 7:32 AM Willem de Bruijn wrote: > > Alexei Starovoitov wrote: > > On Sun, Mar 30, 2025 at 8:27 PM Jiayuan Chen wrote: > > > > > > The device allocates an skb, it additionally allocates a prepad size > > > (usually equal to NET_SKB_PA

Re: [PATCH bpf-next 11/11] bpf: Fall back to nospec for spec path verification

2025-04-03 Thread Alexei Starovoitov
On Wed, Mar 19, 2025 at 2:06 AM Luis Gerhorst wrote: > > Thank you very much for having a look. Let me know whether the above > resolves your concern. > > In any case, should I separate patches 1-3 into another series? Sorry for the delay. lsfmm was followed by the busy merge window. Please reba

Re: [PATCH bpf v2 1/2] bpf, xdp: clean head/meta when expanding it

2025-04-03 Thread Alexei Starovoitov
On Sun, Mar 30, 2025 at 8:27 PM Jiayuan Chen wrote: > > The device allocates an skb, it additionally allocates a prepad size > (usually equal to NET_SKB_PAD or XDP_PACKET_HEADROOM) but leaves it > uninitialized. > > The bpf_xdp_adjust_head function moves skb->data forward, which allows > users to

Re: [PATCH bpf-next 11/11] bpf: Fall back to nospec for spec path verification

2025-03-18 Thread Alexei Starovoitov
On Thu, Mar 13, 2025 at 10:57 AM Luis Gerhorst wrote: > > This trades verification complexity for runtime overheads due to the > nospec inserted because of the EINVAL. > > With increased limits this allows applying mitigations to large BPF > progs such as the Parca Continuous Profiler's prog. Howe

Re: [PATCH] selftests/bpf: Replace deprecated strncpy() with strscpy()

2025-03-17 Thread Alexei Starovoitov
On Mon, Mar 17, 2025 at 12:47 AM wrote: > > From: FengWei > > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead and remove the manual NUL-termination. > > Signed-off-by: FengWei > --- > tools/testing/selftests/bpf/test_verifier.c | 3 +-- > 1 file changed,

Re: [PATCH v7 bpf-next 2/2] selftests/bpf: Add a kernel flag test for LSM bpf hook

2025-03-11 Thread Alexei Starovoitov
On Tue, Mar 11, 2025 at 12:07 AM Song Liu wrote: > > + lskel = kfunc_call_test_lskel__open_and_load(); > > + if (!ASSERT_ERR_PTR(lskel, "lskel")) > > + goto close_prog; > > This goto is not necessary. But I don't think we need v8 just for this. I left goto as-is while ap

Re: [PATCH bpf-next v1 0/3] Optimize bpf selftest to increase CI success rate

2025-02-27 Thread Alexei Starovoitov
On Thu, Feb 27, 2025 at 6:27 AM Jiayuan Chen wrote: > > 1. Optimized some static bound port selftests to avoid port occupation > when running test_progs -j. > 2. Optimized the retry logic for test_maps. Looks great. Applied. Thank you for fixing them.

Re: [RESEND] [PATCH bpf-next 2/3] bpf: Overwrite the element in hash map atomically

2025-02-26 Thread Alexei Starovoitov
On Wed, Feb 26, 2025 at 6:43 PM Hou Tao wrote: > > >> > >> lookup procedure A > >> A: find the old element (instead of the new old) > >> > >> update procedure B > >> B: delete the old element > >> update procedure C on the same CPU: > >> C: r

Re: [RESEND] [PATCH bpf-next 2/3] bpf: Overwrite the element in hash map atomically

2025-02-26 Thread Alexei Starovoitov
On Wed, Feb 26, 2025 at 5:48 PM Hou Tao wrote: > > Hi, > > On 2/27/2025 7:17 AM, Zvi Effron wrote: > > On Tue, Feb 25, 2025 at 9:42 PM Alexei Starovoitov > > wrote: > >> On Tue, Feb 25, 2025 at 8:05 PM Hou Tao wrote: > >>> Hi, > >>&

Re: [PATCH RFC v2 03/10] locking/local_lock: Introduce localtry_lock_t

2025-02-26 Thread Alexei Starovoitov
On Wed, Feb 26, 2025 at 9:01 AM Davidlohr Bueso wrote: > > On Fri, 14 Feb 2025, Vlastimil Babka wrote: > > >From: Sebastian Andrzej Siewior > > > >In !PREEMPT_RT local_lock_irqsave() disables interrupts to protect > >critical section, but it doesn't prevent NMI, so the fully reentrant > >code can

Re: [RESEND] [PATCH bpf-next 2/3] bpf: Overwrite the element in hash map atomically

2025-02-25 Thread Alexei Starovoitov
On Tue, Feb 25, 2025 at 8:05 PM Hou Tao wrote: > > Hi, > > On 2/26/2025 11:24 AM, Alexei Starovoitov wrote: > > On Sat, Feb 8, 2025 at 2:17 AM Hou Tao wrote: > >> Hi Toke, > >> > >> On 2/6/2025 11:05 PM, Toke Høiland-Jørgensen wrote: >

Re: [RESEND] [PATCH bpf-next 2/3] bpf: Overwrite the element in hash map atomically

2025-02-25 Thread Alexei Starovoitov
On Sat, Feb 8, 2025 at 2:17 AM Hou Tao wrote: > > Hi Toke, > > On 2/6/2025 11:05 PM, Toke Høiland-Jørgensen wrote: > > Hou Tao writes: > > > >> +cc Cody Haas > >> > >> Sorry for the resend. I sent the reply in the HTML format. > >> > >> On 2/4/2025 4:28 PM, Hou Tao wrote: > >>> Currently, the upd

Re: [PATCH bpf-next 0/3] selftests/bpf: tc_links/tc_opts: Unserialize tests

2025-02-18 Thread Alexei Starovoitov
On Tue, Feb 18, 2025 at 1:22 PM Stanislav Fomichev wrote: > > On 02/17, Bastien Curutchet (eBPF Foundation) wrote: > > Hi all, > > > > Both tc_links.c and tc_opts.c do their tests on the loopback interface. > > It prevents from parallelizing their executions. > > > > Use namespaces and the new app

Re: [PATCH RFC v2 03/10] locking/local_lock: Introduce localtry_lock_t

2025-02-18 Thread Alexei Starovoitov
On Mon, Feb 17, 2025 at 6:35 AM Vlastimil Babka wrote: > > On 2/17/25 15:19, Sebastian Andrzej Siewior wrote: > > On 2025-02-14 17:27:39 [+0100], Vlastimil Babka wrote: > >> From: Sebastian Andrzej Siewior > >> > >> In !PREEMPT_RT local_lock_irqsave() disables interrupts to protect > >> critical

Re: [RFC PATCH 0/2] livepatch: Add support for hybrid mode

2025-02-08 Thread Alexei Starovoitov
On Sat, Feb 8, 2025 at 11:32 AM Josh Poimboeuf wrote: > > On Sat, Feb 08, 2025 at 07:47:12AM -0800, Alexei Starovoitov wrote: > > On Fri, Feb 7, 2025 at 10:42 PM Yafang Shao wrote: > > > > > > On Fri, Feb 7, 2025 at 2:01 AM Song Liu wrote: > > > > >

Re: [RFC PATCH 0/2] livepatch: Add support for hybrid mode

2025-02-08 Thread Alexei Starovoitov
On Fri, Feb 7, 2025 at 10:42 PM Yafang Shao wrote: > > On Fri, Feb 7, 2025 at 2:01 AM Song Liu wrote: > > > > On Wed, Feb 5, 2025 at 6:55 PM Yafang Shao wrote: > > [...] > > > > I think we should first understand why the trampoline is not > > > > freed. > > > > > > IIUC, the fexit works as follo

Re: [PATCH v2 bpf 1/2] bpf: skip non exist keys in generic_map_lookup_batch

2025-02-07 Thread Alexei Starovoitov
On Thu, Feb 6, 2025 at 9:45 PM Yan Zhai wrote: > > The generic_map_lookup_batch currently returns EINTR if it fails with > ENOENT and retries several times on bpf_map_copy_value. The next batch > would start from the same location, presuming it's a transient issue. > This is incorrect if a map can

Re: [PATCH 2/2] selftests/bpf: Select NUMA node of current CPU to create map

2025-01-25 Thread Alexei Starovoitov
On Sat, Jan 25, 2025 at 7:25 AM Saket Kumar Bhaskar wrote: > > On powerpc, a CPU does not necessarily originate from NUMA node 0. > This contrasts with architectures like x86, where CPU 0 is not > hot-pluggable, making NUMA node 0 a consistently valid node. > This discrepancy can lead to failures

Re: [PATCH] bpf: Fix mix-up of 4096 and page size.

2025-01-23 Thread Alexei Starovoitov
On Wed, Jan 22, 2025 at 10:38 AM Saket Kumar Bhaskar wrote: > > For platforms on powerpc architecture with a default page size greater > than 4096, there was an inconsistency in fragment size calculation. > This caused the BPF selftest xdp_adjust_tail/xdp_adjust_frags_tail_grow > to fail on powerp

Re: [PATCH rcu 13/17] srcu: Add SRCU-fast readers

2025-01-16 Thread Alexei Starovoitov
On Thu, Jan 16, 2025 at 1:55 PM Paul E. McKenney wrote: > > On Thu, Jan 16, 2025 at 01:00:24PM -0800, Alexei Starovoitov wrote: > > On Thu, Jan 16, 2025 at 12:21 PM Paul E. McKenney > > wrote: > > > > > > +/* > > > + * Counts the new rea

Re: [PATCH rcu 13/17] srcu: Add SRCU-fast readers

2025-01-16 Thread Alexei Starovoitov
On Thu, Jan 16, 2025 at 12:21 PM Paul E. McKenney wrote: > > +/* > + * Counts the new reader in the appropriate per-CPU element of the > + * srcu_struct. Returns a pointer that must be passed to the matching > + * srcu_read_unlock_fast(). > + * > + * Note that this_cpu_inc() is an RCU read-side c

Re: [PATCH v2 0/3] sysfs: constify bin_attribute argument of sysfs_bin_attr_simple_read()

2025-01-08 Thread Alexei Starovoitov
On Tue, Dec 31, 2024 at 2:30 AM Thomas Weißschuh wrote: > > On 2024-12-30 16:50:41-0800, Alexei Starovoitov wrote: > > On Sat, Dec 28, 2024 at 12:43 AM Thomas Weißschuh > > wrote: > > > > > > Most users use this function through the BIN_ATTR_SIMPLE* macr

Re: [PATCH v2 0/3] sysfs: constify bin_attribute argument of sysfs_bin_attr_simple_read()

2024-12-30 Thread Alexei Starovoitov
On Sat, Dec 28, 2024 at 12:43 AM Thomas Weißschuh wrote: > > Most users use this function through the BIN_ATTR_SIMPLE* macros, > they can handle the switch transparently. > > This series is meant to be merged through the driver core tree. hmm. why? I'd rather take patches 2 and 3 into bpf-next t

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

2024-12-19 Thread Alexei Starovoitov
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 test I can come up with is: > > > > > > u8 vals[8]; > > > vals[0] = 0; > > > ... > > > vals[6] = 0; > > > vals[7] = 0xf; > >

Re: [PATCH bpf-next v3 1/2] bpf, verifier: Improve precision of BPF_MUL

2024-12-16 Thread Alexei Starovoitov
On Sat, Dec 14, 2024 at 11:04 AM Matan Shachnai wrote: > > This patch improves (or maintains) the precision of register value tracking > in BPF_MUL across all possible inputs. It also simplifies > scalar32_min_max_mul() and scalar_min_max_mul(). > > As it stands, BPF_MUL is composed of three funct

Re: [PATCH v1] selftests/bpf: Fix unnecessary conversion to bool in 'run_subtest'

2024-11-25 Thread Alexei Starovoitov
On Tue, Nov 19, 2024 at 1:36 AM guanjing wrote: > > Fixes the following coccicheck: > > tools/testing/selftests/bpf/test_loader.c:1033:64-69: WARNING: conversion to > bool not needed here > > Fixes: 80a4129fcf20 ("selftests/bpf: Add unit tests for > bpf_arena_alloc/free_pages") > Signed-off-by:

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

2024-10-03 Thread Alexei Starovoitov
On Wed, Oct 2, 2024 at 5:12 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 > the lookup will be in-bounds, allow the prog to drop the null check. > > This is useful for two reas

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

2024-09-25 Thread Alexei Starovoitov
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(struct bpf_verifier_env *env, > +struct bpf_reg_state *key) > +{ > + struct bpf_func_state *state = func(env, k

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

2024-09-10 Thread Alexei Starovoitov
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 > produce / prog consume. > > For example, we want to track the latency overhead of cpumap in > production.

Re: [PATCH rcu 07/11] srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite()

2024-09-03 Thread Alexei Starovoitov
On Tue, Sep 3, 2024 at 9:33 AM Paul E. McKenney wrote: > > diff --git a/include/linux/srcu.h b/include/linux/srcu.h > index 84daaa33ea0ab..4ba96e2cfa405 100644 > --- a/include/linux/srcu.h > +++ b/include/linux/srcu.h ... > +static inline int srcu_read_lock_lite(struct srcu_struct *ssp) > __acqu

Re: [PATCH bpf-next 1/2] bpf: implement bpf_send_signal_pid/tgid() helpers

2024-07-24 Thread Alexei Starovoitov
On Wed, Jul 24, 2024 at 4:40 AM Puranjay Mohan wrote: > > Implement bpf_send_signal_pid and bpf_send_signal_tgid helpers which are > similar to bpf_send_signal_thread and bpf_send_signal helpers > respectively but can be used to send signals to other threads and > processes. Thanks for working on

Re: [PATCH v2 4/7] bpf: support error injection static keys for multi_link attached progs

2024-06-25 Thread Alexei Starovoitov
On Wed, Jun 19, 2024 at 3:49 PM Vlastimil Babka wrote: > > Functions marked for error injection can have an associated static key > that guards the callsite(s) to avoid overhead of calling an empty > function when no error injection is in progress. > > Outside of the error injection framework itse

Re: [PATCH v2 6/7] mm, slab: add static key for should_failslab()

2024-06-25 Thread Alexei Starovoitov
On Tue, Jun 25, 2024 at 7:24 AM Vlastimil Babka wrote: > > On 6/20/24 12:49 AM, Vlastimil Babka wrote: > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -3874,13 +3874,37 @@ static __always_inline void > > maybe_wipe_obj_freeptr(struct kmem_cache *s, > > 0, sizeof(void *)); > >

Re: [PATCH v2 5/7] bpf: do not create bpf_non_sleepable_error_inject list when unnecessary

2024-06-19 Thread Alexei Starovoitov
On Wed, Jun 19, 2024 at 3:49 PM Vlastimil Babka wrote: > > When CONFIG_FUNCTION_ERROR_INJECTION is disabled, > within_error_injection_list() will return false for any address and the > result of check_non_sleepable_error_inject() denylist is thus redundant. > The bpf_non_sleepable_error_inject lis

Re: [PATCH RFC 3/4] mm, slab: add static key for should_failslab()

2024-06-02 Thread Alexei Starovoitov
On Sat, Jun 1, 2024 at 1:57 PM Vlastimil Babka wrote: > > On 5/31/24 6:43 PM, Alexei Starovoitov wrote: > > On Fri, May 31, 2024 at 2:33 AM Vlastimil Babka wrote: > >> might_alloc(flags); > >> > >> - if (unlikely(should_failslab(s, fl

Re: [PATCH RFC 3/4] mm, slab: add static key for should_failslab()

2024-05-31 Thread Alexei Starovoitov
t; might_alloc(flags); > > - if (unlikely(should_failslab(s, flags))) > - return NULL; > + if (static_branch_unlikely(&should_failslab_active)) { > + if (should_failslab(s, flags)) > + return NULL; > + } makes sense. Acked-by: Alexei Starovoitov Do you have any microbenchmark numbers before/after this optimization?

Re: [PATCHv6 bpf-next 0/9] uprobe: uretprobe speed up

2024-05-21 Thread Alexei Starovoitov
On Tue, May 21, 2024 at 1:49 PM Deepak Gupta wrote: > > On Tue, May 21, 2024 at 12:48:16PM +0200, Jiri Olsa wrote: > >hi, > >as part of the effort on speeding up the uprobes [0] coming with > >return uprobe optimization by using syscall instead of the trap > >on the uretprobe trampoline. > > I und

Re: WARNING: kmalloc bug in bpf_uprobe_multi_link_attach

2024-05-15 Thread Alexei Starovoitov
On Tue, May 14, 2024 at 12:33 AM Ubisectech Sirius wrote: > > Hello. > We are Ubisectech Sirius Team, the vulnerability lab of China ValiantSec. > Recently, our team has discovered a issue in Linux kernel 6.7. Attached to > the email were a PoC file of the issue. Jiri, please take a look. >

Re: [PATCH v4 02/14] mm: Switch mm->get_unmapped_area() to a flag

2024-03-25 Thread Alexei Starovoitov
ICK_MMAP_LAYOUT) > void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) > { > mm->mmap_base = TASK_UNMAPPED_BASE; > - mm->get_unmapped_area = arch_get_unmapped_area; > + clear_bit(MMF_TOPDOWN, &mm->flags); > } > #endif Makes sense to me. Acked-by: Alexei Starovoitov for the idea and for bpf bits.

raw_tp+cookie is buggy. Was: [syzbot] [bpf?] [trace?] KASAN: slab-use-after-free Read in bpf_trace_run1

2024-03-25 Thread Alexei Starovoitov
Hi Andrii, syzbot found UAF in raw_tp cookie series in bpf-next. Reverting the whole merge 2e244a72cd48 ("Merge branch 'bpf-raw-tracepoint-support-for-bpf-cookie'") fixes the issue. Pls take a look. See C reproducer below. It splats consistently with CONFIG_KASAN=y Thanks. On Sun, Mar 24, 2024

Re: [PATCH v5 00/12] tracing: fprobe: rethook: Use ftrace_regs instead of pt_regs

2023-09-29 Thread Alexei Starovoitov
On Thu, Sep 28, 2023 at 6:21 PM Masami Hiramatsu wrote: > > > Thus, what I need is to make fprobe to use function-graph tracer's shadow > stack and trampoline instead of rethook. This may need to generalize its > interface so that we can share it between fprobe and function-graph tracer, > but we

Re: [PATCH bpf-next v5 2/6] bpf: Add a ARG_PTR_TO_CONST_STR argument type

2021-04-20 Thread Alexei Starovoitov
On Tue, Apr 20, 2021 at 5:35 AM Florent Revest wrote: > > On Tue, Apr 20, 2021 at 12:54 AM Alexei Starovoitov > wrote: > > > > On Mon, Apr 19, 2021 at 05:52:39PM +0200, Florent Revest wrote: > > > This type provides the guarantee that an argument is going to be a co

Re: [PATCH bpf-next 1/2] bpf: Remove bpf_jit_enable=2 debugging mode

2021-04-19 Thread Alexei Starovoitov
On Sat, Apr 17, 2021 at 1:16 AM Christophe Leroy wrote: > > > > Le 16/04/2021 à 01:49, Alexei Starovoitov a écrit : > > On Thu, Apr 15, 2021 at 8:41 AM Quentin Monnet > > wrote: > >> > >> 2021-04-15 16:37 UTC+0200 ~ Daniel Borkmann > >>

Re: [PATCH bpf-next v2] bpf: Fix some invalid links in bpf_devel_QA.rst

2021-04-19 Thread Alexei Starovoitov
On Wed, Apr 14, 2021 at 4:20 AM Tiezhu Yang wrote: > > There exist some errors "404 Not Found" when I click the link > of "MAINTAINERS" [1], "samples/bpf/" [2] and "selftests" [3] > in the documentation "HOWTO interact with BPF subsystem" [4]. > > Use correct link of "MAINTAINERS" and just remove

Re: [PATCH bpf-next v5 2/6] bpf: Add a ARG_PTR_TO_CONST_STR argument type

2021-04-19 Thread Alexei Starovoitov
On Mon, Apr 19, 2021 at 05:52:39PM +0200, Florent Revest wrote: > This type provides the guarantee that an argument is going to be a const > pointer to somewhere in a read-only map value. It also checks that this > pointer is followed by a zero character before the end of the map value. > > Signed

Re: [PATCH] bpf: fix errno code for unsupported batch ops

2021-04-19 Thread Alexei Starovoitov
On Mon, Apr 19, 2021 at 6:52 AM Pedro Tammela wrote: > > Em dom., 18 de abr. de 2021 às 19:56, Alexei Starovoitov > escreveu: > > > > On Sun, Apr 18, 2021 at 1:03 PM Pedro Tammela wrote: > > > > > > ENOTSUPP is not a valid userland errno[1], which is a

Re: [PATCH] bpf: fix errno code for unsupported batch ops

2021-04-18 Thread Alexei Starovoitov
On Sun, Apr 18, 2021 at 1:03 PM Pedro Tammela wrote: > > ENOTSUPP is not a valid userland errno[1], which is annoying for > userland applications that implement a fallback to iterative, report > errors via 'strerror()' or both. > > The batched ops return this errno whenever an operation > is not i

Re: [PATCH bpf-next 1/2] bpf: Remove bpf_jit_enable=2 debugging mode

2021-04-15 Thread Alexei Starovoitov
On Thu, Apr 15, 2021 at 8:41 AM Quentin Monnet wrote: > > 2021-04-15 16:37 UTC+0200 ~ Daniel Borkmann > > On 4/15/21 11:32 AM, Jianlin Lv wrote: > >> For debugging JITs, dumping the JITed image to kernel log is discouraged, > >> "bpftool prog dump jited" is much better way to examine JITed dumps.

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 9:32 AM wrote: > > > -Original Message- > > From: Alexei Starovoitov > > > > On Tue, Apr 13, 2021 at 9:19 AM wrote: > > > > > > > -Original Message- > > > > From: Alexei Starovo

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 9:19 AM wrote: > > > -Original Message- > > From: Alexei Starovoitov > > > > On Tue, Apr 13, 2021 at 9:10 AM wrote: > > > > > > > > > > > > > -Original Message- > > > > Fro

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 9:10 AM wrote: > > > > > -Original Message- > > From: Alexei Starovoitov > > > > On Tue, Apr 13, 2021 at 2:52 AM Yang Li wrote: > > > > > > Fix the following coccicheck warnings: > > > ./tools/

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 2:52 AM Yang Li wrote: > > Fix the following coccicheck warnings: > ./tools/testing/selftests/bpf/progs/profiler.inc.h:189:7-11: WARNING > comparing pointer to 0, suggest !E > ./tools/testing/selftests/bpf/progs/profiler.inc.h:361:7-11: WARNING > comparing pointer to 0, sug

Re: BUG: unable to handle kernel paging request in bpf_check

2021-04-12 Thread Alexei Starovoitov
On Mon, Apr 12, 2021 at 12:11 AM Hao Sun wrote: > > Besides, another similar bug occurred while fault injection was enabled. > > BUG: unable to handle kernel paging request in bpf_prog_alloc_no_stats > > RAX: ffda RBX: 0

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-03 Thread Alexei Starovoitov
On Sat, Apr 03, 2021 at 12:38:06AM +0530, Kumar Kartikeya Dwivedi wrote: > On Sat, Apr 03, 2021 at 12:02:14AM IST, Alexei Starovoitov wrote: > > On Fri, Apr 2, 2021 at 8:27 AM Kumar Kartikeya Dwivedi > > wrote: > > > [...] > > > > All of these things are mess

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-02 Thread Alexei Starovoitov
On Fri, Apr 2, 2021 at 8:27 AM Kumar Kartikeya Dwivedi wrote: > > This would be fine, because it's not a fast path or anything, but right now we > return the id using the netlink response, otherwise for query we have to open > the socket, prepare the msg, send and recv again. So it's a minor > op

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-03-30 Thread Alexei Starovoitov
On Tue, Mar 30, 2021 at 2:26 PM Daniel Borkmann wrote: > > On 3/30/21 10:39 PM, Andrii Nakryiko wrote: > > On Sun, Mar 28, 2021 at 1:11 AM Kumar Kartikeya Dwivedi > > wrote: > >> On Sun, Mar 28, 2021 at 10:12:40AM IST, Andrii Nakryiko wrote: > >>> Is there some succinct but complete enough docume

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-30 Thread Alexei Starovoitov
On Tue, Mar 30, 2021 at 1:28 PM Andrii Nakryiko wrote: > > > > In the other thread you've proposed to copy paste hash implemenation > > into pahole. That's not ideal. If we had libbpfutil other projects > > could have used that without copy-paste. > > I know it's not ideal. But I don't think libbp

Re: [PATCH bpf-next v2] bpf: check flags in 'bpf_ringbuf_discard()' and 'bpf_ringbuf_submit()'

2021-03-30 Thread Alexei Starovoitov
On Tue, Mar 30, 2021 at 3:54 PM Pedro Tammela wrote: > > BPF_CALL_2(bpf_ringbuf_submit, void *, sample, u64, flags) > { > + if (unlikely(flags & ~(BPF_RB_NO_WAKEUP | BPF_RB_FORCE_WAKEUP))) > + return -EINVAL; > + > bpf_ringbuf_commit(sample, flags, false /* discard */

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-29 Thread Alexei Starovoitov
On Sun, Mar 28, 2021 at 07:38:42PM -0700, Andrii Nakryiko wrote: > > See above. I don't know which hassle is libbpf for users today. You > were implying code size used for functionality users might not use > (e.g., linker). Libbpf is a very small library, <300KB. There are > users building tools f

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-28 Thread Alexei Starovoitov
On Sat, Mar 27, 2021 at 09:32:58PM -0700, Andrii Nakryiko wrote: > > I think it's better to start with new library for tc/xdp and have > > libbpf as a dependency on that new lib. > > For example we can add it as subdir in tools/lib/bpf/. > > > > Similarly I think integerating static linking into li

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-28 Thread Alexei Starovoitov
On Sat, Mar 27, 2021 at 04:17:16PM +0100, Toke Høiland-Jørgensen wrote: > Alexei Starovoitov writes: > > > On Thu, Mar 25, 2021 at 05:30:03PM +0530, Kumar Kartikeya Dwivedi wrote: > >> This adds some basic tests for the low level bpf_tc_* API and its > >> bpf_progr

Re: [PATCH bpf-next] bpf: tcp: Remove comma which is causing build error

2021-03-28 Thread Alexei Starovoitov
On Sun, Mar 28, 2021 at 5:05 AM Atul Gopinathan wrote: > > Currently, building the bpf-next source with the CONFIG_BPF_SYSCALL > enabled is causing a compilation error: > > "net/ipv4/bpf_tcp_ca.c:209:28: error: expected identifier or '(' before > ',' token" > > Fix this by removing an unnecessary

Re: [PATCH bpf-next] bpf: trace jit code when enable BPF_JIT_ALWAYS_ON

2021-03-27 Thread Alexei Starovoitov
On Sat, Mar 27, 2021 at 1:19 AM Jianlin Lv wrote: > > > On Fri, Mar 26, 2021 at 5:40 AM Jianlin Lv wrote: > > > > > > When CONFIG_BPF_JIT_ALWAYS_ON is enabled, the value of > > bpf_jit_enable > > > in /proc/sys is limited to SYSCTL_ONE. This is not convenient for > > > debugging. > > > This patc

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-26 Thread Alexei Starovoitov
On Thu, Mar 25, 2021 at 05:30:03PM +0530, Kumar Kartikeya Dwivedi wrote: > This adds some basic tests for the low level bpf_tc_* API and its > bpf_program__attach_tc_* wrapper on top. *_block() apis from patch 3 and 4 are not covered by this selftest. Why were they added ? And how were they tested

Re: [PATCH bpf-next] bpf: trace jit code when enable BPF_JIT_ALWAYS_ON

2021-03-26 Thread Alexei Starovoitov
On Fri, Mar 26, 2021 at 5:40 AM Jianlin Lv wrote: > > When CONFIG_BPF_JIT_ALWAYS_ON is enabled, the value of bpf_jit_enable in > /proc/sys is limited to SYSCTL_ONE. This is not convenient for debugging. > This patch modifies the value of extra2 (max) to 2 that support developers > to emit traces o

Re: [PATCH bpf-next 2/5] bpf: Add a bpf_snprintf helper

2021-03-22 Thread Alexei Starovoitov
On Wed, Mar 10, 2021 at 11:02:08PM +0100, Florent Revest wrote: > > +struct bpf_snprintf_buf { > + char buf[MAX_SNPRINTF_MEMCPY][MAX_SNPRINTF_STR_LEN]; > +}; > +static DEFINE_PER_CPU(struct bpf_snprintf_buf, bpf_snprintf_buf); > +static DEFINE_PER_CPU(int, bpf_snprintf_buf_used); > + > +BPF_C

Re: linux-next: manual merge of the net-next tree with the net tree

2021-03-19 Thread Alexei Starovoitov
On Fri, Mar 19, 2021 at 8:17 AM Yonghong Song wrote: > > > > On 3/19/21 12:21 AM, Daniel Borkmann wrote: > > On 3/19/21 3:11 AM, Piotr Krysiuk wrote: > >> Hi Daniel, > >> > >> On Fri, Mar 19, 2021 at 12:16 AM Stephen Rothwell > >> wrote: > >> > >>> diff --cc kernel/bpf/verifier.c > >>> index 44e4

  1   2   3   4   5   6   7   8   9   10   >