Message ID | 20230409033431.3992432-1-joannelkoong@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | Dynptr convenience helpers | expand |
On Sat, Apr 8, 2023 at 8:34 PM Joanne Koong <joannelkoong@gmail.com> wrote: > > This patchset is the 3rd in the dynptr series. The 1st (dynptr > fundamentals) can be found here [0] and the second (skb + xdp dynptrs) > can be found here [1]. > > This patchset adds the following convenience helpers for interacting > with dynptrs: "convenience helpers" doesn't do these APIs justice. They are necessary APIs to make dynptrs a generic interface for working with memory ranges. So it's dynptr cloning and adjustment helpers, but not just a convenience APIs. > > int bpf_dynptr_trim(struct bpf_dynptr *ptr, __u32 len) __ksym; > int bpf_dynptr_advance(struct bpf_dynptr *ptr, __u32 len) __ksym; > int bpf_dynptr_is_null(const struct bpf_dynptr *ptr) __ksym; > int bpf_dynptr_is_rdonly(const struct bpf_dynptr *ptr) __ksym; > __u32 bpf_dynptr_get_size(const struct bpf_dynptr *ptr) __ksym; > __u32 bpf_dynptr_get_offset(const struct bpf_dynptr *ptr) __ksym; > int bpf_dynptr_clone(const struct bpf_dynptr *ptr, struct bpf_dynptr *clone__init) __ksym; > > [0] https://lore.kernel.org/bpf/20220523210712.3641569-1-joannelkoong@gmail.com/ > [1] https://lore.kernel.org/bpf/20230301154953.641654-1-joannelkoong@gmail.com/ > > Joanne Koong (5): > bpf: Add bpf_dynptr_trim and bpf_dynptr_advance > bpf: Add bpf_dynptr_is_null and bpf_dynptr_is_rdonly > bpf: Add bpf_dynptr_get_size and bpf_dynptr_get_offset > bpf: Add bpf_dynptr_clone > selftests/bpf: add tests for dynptr convenience helpers > > include/linux/bpf.h | 2 +- > kernel/bpf/helpers.c | 108 +++++- > kernel/bpf/verifier.c | 125 ++++++- > kernel/trace/bpf_trace.c | 4 +- > tools/testing/selftests/bpf/bpf_kfuncs.h | 8 + > .../testing/selftests/bpf/prog_tests/dynptr.c | 6 + > .../testing/selftests/bpf/progs/dynptr_fail.c | 313 +++++++++++++++++ > .../selftests/bpf/progs/dynptr_success.c | 320 ++++++++++++++++++ > 8 files changed, 864 insertions(+), 22 deletions(-) > > -- > 2.34.1 >