Skip to content

Add user-space and non-CO-RE variants of BPF_CORE_READ()

Andrii Nakryiko bpf netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3libbpf: add user-space variants of BPF_CORE_READ() family of macrostools/lib/bpf/bpf_core_read.h+59 -390 replies
2/3libbpf: add non-CO-RE variants of BPF_CORE_READ() macro familytools/lib/bpf/bpf_core_read.h+38 -00 replies
3/3selftests/bpf: add tests for user- and non-CO-RE BPF_CORE_READ() variantstools/testing/selftests/bpf/prog_tests/core_read_macros.c tools/testing/selftests/bpf/progs/test_core_read_macros.c+115 -08 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/3] Add user-space and non-CO-RE variants of BPF_CORE_READ()

Add two sets of BPF_CORE_READ()-like macros. One is for reading kernel data from user address space (e.g., UAPI data structs for syscalls). Another one is non-CO-RE variants, which don't emit CO-RE relocations and thus won't fail on kernels without BTF. The latter one still provides much shorter way to write reads that needs to chase few pointers.

Andrii Nakryiko (3):
libbpf: add user-space variants of BPF_CORE_READ() family of macros
libbpf: add non-CO-RE variants of BPF_CORE_READ() macro family selftests/bpf: add tests for user- and non-CO-RE BPF_CORE_READ()
variants

 tools/lib/bpf/bpf_core_read.h                 | 136 +++++++++++++-----
 .../bpf/prog_tests/core_read_macros.c         |  64 +++++++++
 .../bpf/progs/test_core_read_macros.c         |  51 +++++++
 3 files changed, 212 insertions(+), 39 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/core_read_macros.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_core_read_macros.c
Signature · 1 line
2.24.1