Re: [PATCH bpf,v2,0/2] bpf: fix incorrect name check pass logic in btf_name_valid_section

2024-09-04 Thread Eduard Zingerman
On Sat, 2024-08-31 at 14:45 +0900, Jeongjun Park wrote: > This patch was written to fix an issue where btf_name_valid_section() would > not properly check names with certain conditions and would throw an OOB vuln. > And selftest was added to verify this patch. Acked-by: Eduard Zingerman [...]

Re: [PATCH] selftests/bpf: Add missing va_end.

2024-09-24 Thread Eduard Zingerman
On Tue, 2024-09-24 at 12:55 +0800, zhangjiao2 wrote: > From: zhang jiao > > There is no va_end after va_copy, just add it. > > Signed-off-by: zhang jiao > --- My bad, thank you for fixing this. Acked-by: Eduard Zingerman

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

2024-09-24 Thread Eduard Zingerman
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 > --- Acked-by: Eduard Zingerman [...] > +/* Returns constant key value if possible, else -1 */ > +static long get_constant

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

2024-09-20 Thread Eduard Zingerman
up. And obviously some bound checks. > > Signed-off-by: Daniel Xu > --- Acked-by: Eduard Zingerman [...]

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

2024-09-20 Thread Eduard Zingerman
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 > the lookup will be in-bounds, allow the prog to drop the null check. > > This is useful for two re

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

2025-01-02 Thread Eduard Zingerman
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 s64 get_constant_map_key(struct bpf_verifier_env *env, > + struct bpf_reg_state *key, > +

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

2025-02-03 Thread Eduard Zingerman
On Sat, 2025-02-01 at 12:58 -0700, Daniel Xu wrote: > 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 > --- Acked-by: Eduard Zingerman [...]

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

2025-01-30 Thread Eduard Zingerman
tatic); - when only static libraries are available. Tested-by: Eduard Zingerman [...]

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

2024-12-12 Thread Eduard Zingerman
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 58b36cc96bd5..4947ef884a18 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c > @@ -287,6 +287,7 @@ st

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

2024-12-12 Thread Eduard Zingerman
ates for examples. > > Signed-off-by: Daniel Xu > --- I think this change is ok. With it there is only one use of 'enum bpf_access_src' remains, but it doesn't look like it could be removed. Acked-by: Eduard Zingerman [...] > --- a/tools/testing/selftests/bpf/pr

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

2024-12-13 Thread Eduard Zingerman
On Sat, 2024-12-14 at 00:10 +0100, Kumar Kartikeya Dwivedi wrote: [...] > > @@ -11199,10 +11266,17 @@ static int check_helper_call(struct > > bpf_verifier_env *env, struct bpf_insn *insn > > "kernel subsystem misconfigured > > verifier\n"); > >

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

2024-12-13 Thread Eduard Zingerman
On Fri, 2024-12-13 at 15:14 -0800, Eduard Zingerman wrote: [...] > Great point, I'm sure this does not happen. I mean, mark_chain_precision() does not happen at the moment.

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

2024-12-13 Thread Eduard Zingerman
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 when there's both const and non-const values of R2 leading up to > a lookup. And obviously

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

2024-12-13 Thread Eduard Zingerman
On Fri, 2024-12-13 at 19:44 -0700, Daniel Xu wrote: [...] > > > + /* First handle precisely tracked STACK_ZERO, up to BPF_REG_SIZE > > > */ > > > + stype = state->stack[spi].slot_type; > > > + for (i = 0; i < BPF_REG_SIZE && stype[i] == STACK_ZERO; i++) > > > > it's Friday and

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

2024-12-19 Thread Eduard Zingerman
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 > > > v > > > 000f <-- written to stack as a single u64 value > > > ^^^ > > > stack zero marks > > > > > > and is ex

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

2024-12-19 Thread Eduard Zingerman
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; > > p = bpf_map_lookup_elem(... vals ...); > > *p = 42; > > > > For LE vals

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

2025-01-02 Thread Eduard Zingerman
On Thu, 2024-12-19 at 21:09 -0700, Daniel Xu wrote: > Test that nullness elision works for common use cases. For example, we > want to check that both constant scalar spills and STACK_ZERO functions. > As well as when there's both const and non-const values of R2 leading up > to a lookup. And obvio

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

2025-03-15 Thread Eduard Zingerman
On Thu, 2025-03-13 at 18:21 +0100, Luis Gerhorst wrote: > This improves the expressiveness of unprivileged BPF by inserting > speculation barriers instead of rejecting the programs. > > The approach was previously presented at LPC'24 [1] and RAID'24 [2]. > > To mitigate the Spectre v1 (PHT) vulne

Re: [PATCH bpf-next 02/11] bpf: Return -EFAULT on misconfigurations

2025-03-15 Thread Eduard Zingerman
gt; Cc: Milan Stephan > --- The only pace I'm aware of that might act upon specific error code from verifier syscall is libbpf. Looking through libbpf code, it seems that this change does not interfere with libbpf. Reviewed-by: Eduard Zingerman [...]

Re: [PATCH bpf-next 03/11] bpf: Return -EFAULT on internal errors

2025-03-15 Thread Eduard Zingerman
me as for previous patch. Reviewed-by: Eduard Zingerman [...]

Re: [PATCH bpf-next 01/11] bpf: Move insn if/else into do_check_insn()

2025-03-14 Thread Eduard Zingerman
On Thu, 2025-03-13 at 18:21 +0100, Luis Gerhorst wrote: > This is required to catch the errors later and fall back to a nospec if > on a speculative path. > > Move code into do_check_insn(), replace > * "continue" with "return INSN_IDX_MODIFIED" > * "goto process_bpf_exit" with "return PROCESS_BPF

Re: [PATCH bpf-next 09/11] bpf: Return PTR_ERR from push_stack()

2025-03-17 Thread Eduard Zingerman
On Thu, 2025-03-13 at 18:41 +0100, Luis Gerhorst wrote: [...] > @@ -2011,8 +2011,10 @@ static struct bpf_verifier_state *push_stack(struct > bpf_verifier_env *env, > int err; > > elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL); > - if (!elem) > -