From: Eduard Zingerman <eddyz87@gmail.com>
To: Daniel Xu <dxu@dxuuu.xyz>,
andrii@kernel.org, ast@kernel.org, shuah@kernel.org,
daniel@iogearbox.net
Cc: john.fastabend@gmail.com, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, mykolal@fb.com,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 3/5] bpf: verifier: Refactor helper access type tracking
Date: Thu, 12 Dec 2024 20:04:28 -0800 [thread overview]
Message-ID: <341df2d52af6c1584353b89a8a65d9d0fb5f0f27.camel@gmail.com> (raw)
In-Reply-To: <4727abf12fbc53723359d4edcdf5b6dd7d33f9cb.1734045451.git.dxu@dxuuu.xyz>
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, all
> calls to check_stack_range_initialized() already have precise access type
> information available.
>
> Rather than treat ACCESS_HELPER as a proxy for BPF_WRITE, pass
> enum bpf_access_type to check_stack_range_initialized() to more
> precisely track helper arguments.
>
> One benefit from this precision is that registers tracked as valid
> spills and passed as a read-only helper argument remain tracked after
> the call. Rather than being marked STACK_MISC afterwards.
>
> 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 <dxu@dxuuu.xyz>
> ---
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 <eddyz87@gmail.com>
[...]
> --- a/tools/testing/selftests/bpf/progs/uninit_stack.c
> +++ b/tools/testing/selftests/bpf/progs/uninit_stack.c
> @@ -55,33 +55,4 @@ exit_%=: r0 = 0; \
> : __clobber_all);
> }
>
> -static __noinline void dummy(void) {}
> -
> -/* Pass a pointer to uninitialized stack memory to a helper.
> - * Passed memory block should be marked as STACK_MISC after helper call.
> - */
> -SEC("socket")
> -__log_level(7) __msg("fp-104=mmmmmmmm")
> -__naked int helper_uninit_to_misc(void *ctx)
Is it possible to peek a helper that writes into memory and not delete
this test?
> -{
> - asm volatile (" \
> - /* force stack depth to be 128 */ \
> - *(u64*)(r10 - 128) = r1; \
> - r1 = r10; \
> - r1 += -128; \
> - r2 = 32; \
> - call %[bpf_trace_printk]; \
> - /* Call to dummy() forces print_verifier_state(..., true), \
> - * thus showing the stack state, matched by __msg(). \
> - */ \
> - call %[dummy]; \
> - r0 = 0; \
> - exit; \
> -"
> - :
> - : __imm(bpf_trace_printk),
> - __imm(dummy)
> - : __clobber_all);
> -}
> -
[...]
next prev parent reply other threads:[~2024-12-13 4:04 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 23:22 [PATCH bpf-next v5 0/5] Support eliding map lookup nullness Daniel Xu
2024-12-12 23:22 ` [PATCH bpf-next v5 1/5] bpf: verifier: Add missing newline on verbose() call Daniel Xu
2024-12-12 23:22 ` [PATCH bpf-next v5 2/5] bpf: tcp: Mark bpf_load_hdr_opt() arg2 as read-write Daniel Xu
2024-12-16 18:18 ` Martin KaFai Lau
2024-12-12 23:22 ` [PATCH bpf-next v5 3/5] bpf: verifier: Refactor helper access type tracking Daniel Xu
2024-12-13 4:04 ` Eduard Zingerman [this message]
2024-12-13 20:02 ` Daniel Xu
2024-12-12 23:22 ` [PATCH bpf-next v5 4/5] bpf: verifier: Support eliding map lookup nullness Daniel Xu
2024-12-13 4:04 ` Eduard Zingerman
2024-12-13 20:57 ` Daniel Xu
2024-12-13 23:02 ` Andrii Nakryiko
2024-12-14 2:44 ` Daniel Xu
2024-12-14 3:13 ` Eduard Zingerman
2024-12-16 23:24 ` Andrii Nakryiko
2024-12-19 0:09 ` Daniel Xu
2024-12-19 21:41 ` Daniel Xu
2024-12-20 0:04 ` Eduard Zingerman
2024-12-20 0:40 ` Daniel Xu
2024-12-20 0:43 ` Eduard Zingerman
2024-12-20 0:49 ` Alexei Starovoitov
2024-12-20 4:00 ` Daniel Xu
2024-12-13 23:10 ` Kumar Kartikeya Dwivedi
2024-12-13 23:14 ` Eduard Zingerman
2024-12-13 23:18 ` Eduard Zingerman
2024-12-12 23:22 ` [PATCH bpf-next v5 5/5] bpf: selftests: verifier: Add nullness elision tests Daniel Xu
2024-12-14 6:17 ` Eduard Zingerman
2024-12-18 1:57 ` Daniel Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=341df2d52af6c1584353b89a8a65d9d0fb5f0f27.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).