From: John Fastabend <john.fastabend@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Joanne Koong <joannelkoong@gmail.com>
Cc: John Fastabend <john.fastabend@gmail.com>,
bpf@vger.kernel.org, andrii@kernel.org, ast@kernel.org,
daniel@iogearbox.net
Subject: Re: [PATCH v2 bpf-next 1/5] bpf: Add bpf_dynptr_adjust
Date: Fri, 28 Apr 2023 14:08:46 -0700 [thread overview]
Message-ID: <644c35de4b083_2c379420868@john.notmuch> (raw)
In-Reply-To: <CAEf4BzbA3DvsQgsgkWnrHUXOnFuL-doVqe2_Yo0=NQDTn5HgKQ@mail.gmail.com>
Andrii Nakryiko wrote:
> On Mon, Apr 24, 2023 at 10:29 PM Joanne Koong <joannelkoong@gmail.com> wrote:
> >
> > On Mon, Apr 24, 2023 at 12:46 PM John Fastabend
> > <john.fastabend@gmail.com> wrote:
> > >
> > > Joanne Koong wrote:
> > > > Add a new kfunc
> > > >
> > > > int bpf_dynptr_adjust(struct bpf_dynptr_kern *ptr, u32 start, u32 end);
> > > >
> > > > which adjusts the dynptr to reflect the new [start, end) interval.
> > > > In particular, it advances the offset of the dynptr by "start" bytes,
> > > > and if end is less than the size of the dynptr, then this will trim the
> > > > dynptr accordingly.
> > > >
> > > > Adjusting the dynptr interval may be useful in certain situations.
> > > > For example, when hashing which takes in generic dynptrs, if the dynptr
> > > > points to a struct but only a certain memory region inside the struct
> > > > should be hashed, adjust can be used to narrow in on the
> > > > specific region to hash.
> > >
> > > Would you want to prohibit creating an empty dynptr with [start, start)?
> >
> > I'm open to either :) I don't reallysee a use case for creating an
> > empty dynptr, but I think the concept of an empty dynptr might be
> > useful in general, so maybe we should let this be okay as well?
>
> Yes, there is no need to artificially enforce a non-empty range. We
> already use pointers to zero-sized memory region in verifier (e.g.,
> Alexei's recent kfunc existence check changes). In general, empty
> range is a valid range and we should strive to have that working
> without assumptions on who and how would use that. As long as it's
> conceptually safe, we should support it.
Ack. Agree sounds good to me.
next prev parent reply other threads:[~2023-04-28 21:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 7:14 [PATCH v2 bpf-next 0/5] Dynptr helpers Joanne Koong
2023-04-20 7:14 ` [PATCH v2 bpf-next 1/5] bpf: Add bpf_dynptr_adjust Joanne Koong
2023-04-20 18:38 ` Alexei Starovoitov
2023-04-21 3:46 ` Joanne Koong
2023-04-22 23:44 ` Alexei Starovoitov
2023-04-25 5:05 ` Joanne Koong
2023-04-25 23:46 ` Alexei Starovoitov
2023-04-26 17:50 ` Andrii Nakryiko
2023-04-24 14:31 ` Eduard Zingerman
2023-04-24 14:33 ` Eduard Zingerman
2023-04-24 19:46 ` John Fastabend
2023-04-25 5:29 ` Joanne Koong
2023-04-26 17:46 ` Andrii Nakryiko
2023-04-28 21:08 ` John Fastabend [this message]
2023-04-20 7:14 ` [PATCH v2 bpf-next 2/5] bpf: Add bpf_dynptr_is_null and bpf_dynptr_is_rdonly Joanne Koong
2023-04-24 19:49 ` John Fastabend
2023-04-20 7:14 ` [PATCH v2 bpf-next 3/5] bpf: Add bpf_dynptr_size Joanne Koong
2023-04-24 19:52 ` John Fastabend
2023-04-20 7:14 ` [PATCH v2 bpf-next 4/5] bpf: Add bpf_dynptr_clone Joanne Koong
2023-04-26 18:16 ` Andrii Nakryiko
2023-04-20 7:14 ` [PATCH v2 bpf-next 5/5] selftests/bpf: add tests for dynptr convenience helpers Joanne Koong
2023-04-26 18:17 ` Andrii Nakryiko
2023-04-26 18:20 ` [PATCH v2 bpf-next 0/5] Dynptr helpers patchwork-bot+netdevbpf
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=644c35de4b083_2c379420868@john.notmuch \
--to=john.fastabend@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=joannelkoong@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.