bpf: allow void* cast using bpf_rdonly_cast()
Status from this message: Applied. Pls send a follow up. Easier to review this way.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest3 patches 4 repliesApplied 3/3
- v13 patches 5 repliesSuperseded
Changes in v3 from the cover letter
- dropped direct numbering for __MAX_BPF_FEAT.
Patches in v3 All 3 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | bpf: add bpf_features enumkernel/ | +6 | 0 replies | Applied |
| 2/3 | bpf: allow void* cast using bpf_rdonly_cast()kernel/ | +61 | 0 replies | Applied |
| 3/3 | selftests/bpf: check operations on untrusted ro pointers to memtools/ tools/ | +145 | 3 replies | Applied |
Reviews trailers per patch
None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Andrii Nakryiko |
|---|---|
| Series | A-b |
| 1/3 | |
| 2/3 | |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next v3 0/3] bpf: allow void* cast using bpf_rdonly_cast()
Currently, pointers returned by bpf_rdonly_cast() have a type of "pointer to btf id", and only casts to structure types are allowed. Access to memory pointed to by these pointers is done through BPF_PROBE_{MEM,MEMSX} instructions and does not produce errors on invalid memory access.
This patch set extends bpf_rdonly_cast() to allow casts to an equivalent of 'void *', effectively replacing bpf_probe_read_kernel() calls in situations where access to individual bytes or integers is necessary.
The mechanism was suggested and explored by Andrii Nakryiko in [1].
To help with detecting support for this feature, an enum bpf_features is added with intended usage as follows:
if (bpf_core_enum_value_exists(enum bpf_features,
BPF_FEAT_RDONLY_CAST_TO_VOID))
...[1] https://github.com/anakryiko/linux/tree/bpf-mem-cast
Changelog:
v2: https://lore.kernel.org/bpf/[email protected]/
v2 -> v3:
- dropped direct numbering for __MAX_BPF_FEAT.
v1: https://lore.kernel.org/bpf/[email protected]/
v1 -> v2:
- renamed BPF_FEAT_TOTAL to __MAX_BPF_FEAT and moved patch introducing bpf_features enum to the start of the series (Alexei);
- dropped patch #3 allowing optout from CAP_SYS_ADMIN drop in prog_tests/verifier.c, use a separate runner in prog_tests/* instead.
Eduard Zingerman (3):
bpf: add bpf_features enum
bpf: allow void* cast using bpf_rdonly_cast() selftests/bpf: check operations on untrusted ro pointers to mem
kernel/bpf/verifier.c | 79 ++++++++-- .../bpf/prog_tests/mem_rdonly_untrusted.c | 9 ++ .../bpf/progs/mem_rdonly_untrusted.c | 136 ++++++++++++++++++ 3 files changed, 212 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/mem_rdonly_untrusted.c create mode 100644 tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c
Signature · 1 line
2.47.1