From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: David Vernet <void@manifault.com>, bpf <bpf@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Joanne Koong <joannelkoong@gmail.com>
Subject: Re: [PATCH bpf-next v1 5/7] bpf: Move PTR_TO_STACK alignment check to process_dynptr_func
Date: Mon, 21 Nov 2022 02:32:05 +0530 [thread overview]
Message-ID: <20221120210205.anfsev2i66alszr3@apollo> (raw)
In-Reply-To: <CAADnVQKcHObiPJ0Hs_5+QnEZwtZQ+9eezvpv_HcLWeq1z+PwqQ@mail.gmail.com>
On Mon, Nov 21, 2022 at 01:10:21AM IST, Alexei Starovoitov wrote:
> On Sun, Nov 20, 2022 at 11:10 AM Kumar Kartikeya Dwivedi
> <memxor@gmail.com> wrote:
> >
> > IMO, there are a certain set of properties that check_func_arg_reg_off provides,
> > you could say that if each register type was a class, then the checks there
> > would be what you would do while constructing them on calling:
> >
> > PtrToStack(off, var_off /* can be const or variable */)
> > PtrToMapValue(off, var_off /* can be const or variable */)
> > PtrToBtfId(off /* must be >= 0 */) /* no var_off */
>
> Just to complicate things a bit... ;)
> There was a request to allow var_off in ptr_to_btf_id.
> Sometimes there are fixed size arrays in structs and
> programs need to iterate those arrays in a loop.
Honestly, I don't see why this case needs var_off.
Each iteration will bump the reg->off while indexing into the flex/fixed size
array. Even ptr += scalar where scalar is known will accumulate into reg->off.
But maybe I missed some specific case.
> Another case is to access flex_array at the end of a struct.
> Like cgroup->ancestors[].
This might, but still, to mark the dst_reg as pointer you need to know whether
the possibly variable offset going beyond type->size is 8-byte aligned, right?
Otherwise the best that could be done conservatively is mark_reg_unknown.
> Both are currently impossible, but the verifier has to
> get this capability.
I guess it will be a very involved change. All over the verifier there are
implicit assumptions in places (after certain checks) that PTR_TO_BTF_ID never
has var_off.
next prev parent reply other threads:[~2022-11-20 21:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 0:01 [PATCH bpf-next v1 0/7] Dynptr refactorings Kumar Kartikeya Dwivedi
2022-11-15 0:01 ` [PATCH bpf-next v1 1/7] bpf: Refactor ARG_PTR_TO_DYNPTR checks into process_dynptr_func Kumar Kartikeya Dwivedi
2022-11-15 4:15 ` Joanne Koong
2022-11-15 0:01 ` [PATCH bpf-next v1 2/7] bpf: Propagate errors from process_* checks in check_func_arg Kumar Kartikeya Dwivedi
2022-11-15 3:53 ` Joanne Koong
2022-11-15 0:01 ` [PATCH bpf-next v1 3/7] bpf: Rework process_dynptr_func Kumar Kartikeya Dwivedi
2022-11-16 18:04 ` Joanne Koong
2022-11-17 21:11 ` David Vernet
2022-11-20 18:06 ` Kumar Kartikeya Dwivedi
2022-11-20 18:16 ` David Vernet
2022-11-15 0:01 ` [PATCH bpf-next v1 4/7] bpf: Rework check_func_arg_reg_off Kumar Kartikeya Dwivedi
2022-11-15 18:24 ` Joanne Koong
2022-11-17 23:42 ` David Vernet
2022-11-20 18:41 ` Kumar Kartikeya Dwivedi
2022-11-21 5:39 ` David Vernet
2022-11-15 0:01 ` [PATCH bpf-next v1 5/7] bpf: Move PTR_TO_STACK alignment check to process_dynptr_func Kumar Kartikeya Dwivedi
2022-11-15 18:29 ` Joanne Koong
2022-11-17 23:49 ` David Vernet
2022-11-20 19:10 ` Kumar Kartikeya Dwivedi
2022-11-20 19:40 ` Alexei Starovoitov
2022-11-20 21:02 ` Kumar Kartikeya Dwivedi [this message]
2022-11-21 7:27 ` David Vernet
2022-12-07 20:41 ` Kumar Kartikeya Dwivedi
2022-11-15 0:01 ` [PATCH bpf-next v1 6/7] bpf: Use memmove for bpf_dynptr_{read,write} Kumar Kartikeya Dwivedi
2022-11-17 23:51 ` David Vernet
2022-11-15 0:01 ` [PATCH bpf-next v1 7/7] selftests/bpf: Add test for dynptr reinit in user_ringbuf callback Kumar Kartikeya Dwivedi
2022-11-15 18:36 ` Joanne Koong
2022-11-15 19:41 ` Kumar Kartikeya Dwivedi
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=20221120210205.anfsev2i66alszr3@apollo \
--to=memxor@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=joannelkoong@gmail.com \
--cc=martin.lau@kernel.org \
--cc=void@manifault.com \
/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