Skip to content

Fix unsafe BPF_PROG_TEST_RUN interface

Lorenz Bauer linux-api netdev 5 versions – Applied

Status from this message: Applied, Thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest4 patches 1 replyApplied
  2. v44 patches 1 replySuperseded
  3. v34 patches 6 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v24 patches4 repliesSuperseded
v13 patches8 repliesSuperseded

Changes in v5 from the cover letter

* Fix up libbpf.map

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/4bpf: respect size hint to BPF_PROG_TEST_RUN if presentinclude/uapi/linux/bpf.h net/bpf/test_run.c+18 -40 replies
2/4tools: sync uapi/linux/bpf.htools/include/uapi/linux/bpf.h+5 -20 replies
3/4libbpf: add bpf_prog_test_run_xattrtools/lib/bpf/bpf.c tools/lib/bpf/bpf.h tools/lib/bpf/libbpf.map+43 -00 replies
4/4selftests: add a test for bpf_prog_test_run_xattrtools/testing/selftests/bpf/test_progs.c+54 -10 replies

Reviews trailers per patch

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

Read the v5 thread

Cover letter [PATCH v5 0/4] Fix unsafe BPF_PROG_TEST_RUN interface

Right now, there is no safe way to use BPF_PROG_TEST_RUN with data_out. This is because bpf_test_finish copies the output buffer to user space without checking its size. This can lead to the kernel overwriting data in user space after the buffer if xdp_adjust_head and friends are in play.

Thanks to everyone for their advice and patience with this patch set!

Changes in v5:
* Fix up libbpf.map

Changes in v4:
* Document bpf_prog_test_run and bpf_prog_test_run_xattr
* Use struct bpf_prog_test_run_attr for return values

Changes in v3:
* Introduce bpf_prog_test_run_xattr instead of modifying the existing function

Changes in v2:
* Make the syscall return ENOSPC if data_size_out is too small
* Make bpf_prog_test_run return EINVAL if size_out is missing
* Document the new behaviour of data_size_out

Lorenz Bauer (4):
bpf: respect size hint to BPF_PROG_TEST_RUN if present
tools: sync uapi/linux/bpf.h
libbpf: add bpf_prog_test_run_xattr
selftests: add a test for bpf_prog_test_run_xattr

 include/uapi/linux/bpf.h                 |  7 ++-
 net/bpf/test_run.c                       | 15 ++++++-
 tools/include/uapi/linux/bpf.h           |  7 ++-
 tools/lib/bpf/bpf.c                      | 23 ++++++++++
 tools/lib/bpf/bpf.h                      | 19 ++++++++
 tools/lib/bpf/libbpf.map                 |  1 +
 tools/testing/selftests/bpf/test_progs.c | 55 +++++++++++++++++++++++-
 7 files changed, 120 insertions(+), 7 deletions(-)
Signature · 1 line
2.19.1