[PATCH v2 bpf-next 0/6] Dynptr convenience helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patchset is the 3rd in the dynptr series. The 1st can be found here [0]
and the 2nd can be found here [1].

In this patchset, the following convenience helpers are added for interacting
with bpf dynamic pointers:

    * bpf_dynptr_data_rdonly
    * bpf_dynptr_trim
    * bpf_dynptr_advance
    * bpf_dynptr_is_null
    * bpf_dynptr_is_rdonly
    * bpf_dynptr_get_size
    * bpf_dynptr_get_offset
    * bpf_dynptr_clone
    * bpf_dynptr_iterator

Querying dynptr information is abstracted to helper functions instead of directly
exposing bpf_dynptr internals because this avoids imposing restrictions on the
dynptr struct in the case of any future modifications, as well as consolidates
any logic for parsing the fields to one place.

In the future, some of these convenience helper calls will be inlined.

Please note that this patchset will be rebased on top of dynptr refactoring/fixes
once that is landed upstream.

[0] https://lore.kernel.org/bpf/20220523210712.3641569-1-joannelkoong@xxxxxxxxx/
[1] https://lore.kernel.org/bpf/20221021011510.1890852-1-joannelkoong@xxxxxxxxx/


v1 -> v2:
v1: https://lore.kernel.org/bpf/20220908000254.3079129-1-joannelkoong@xxxxxxxxx/
* Drop patch adding "bpf_dynptr_data_rdonly"
* Add offset arg for bpf_dynptr_clone, to advance offset for cloned dynptr
* bpf_dynptr_iterator operates on a cloned dynptr instead of the original (Kumar,Andrii)  

Joanne Koong (6):
  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
  bpf: Add bpf_dynptr_iterator
  selftests/bpf: Tests for dynptr convenience helpers

 include/linux/bpf.h                           |   2 +-
 include/uapi/linux/bpf.h                      | 114 ++++
 kernel/bpf/helpers.c                          | 218 ++++++-
 kernel/bpf/verifier.c                         | 205 +++++--
 kernel/trace/bpf_trace.c                      |   4 +-
 scripts/bpf_doc.py                            |   3 +
 tools/include/uapi/linux/bpf.h                | 114 ++++
 .../testing/selftests/bpf/prog_tests/dynptr.c |  31 +
 .../testing/selftests/bpf/progs/dynptr_fail.c | 439 ++++++++++++++
 .../selftests/bpf/progs/dynptr_success.c      | 534 +++++++++++++++++-
 10 files changed, 1601 insertions(+), 63 deletions(-)

-- 
2.30.2




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux