Skip to content

Don't trust r0 bounds after BPF to BPF calls with abnormal returns

Arthur Fabre bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 10 repliesIn review

Changes in v2 from the cover letter

- Handle LD_ABS and LD_IND, not just tail_call()
- Split tests out
- Use inline asm for tests

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Don't trust r0 bounds after BPF to BPF calls with abnormal returnskernel/bpf/verifier.c+12 -61 reply
2/2selftests/bpf: Test r0 bounds after BPF to BPF call with abnormal returntools/testing/selftests/bpf/prog_tests/verifier.c tools/testing/selftests/bpf/progs/verifier_abnormal_ret.c+90 -07 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchEduard Zingerman
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH bpf v2 0/2] Don't trust r0 bounds after BPF to BPF calls with abnormal returns

A BPF function can return before its exit instruction: LD_ABS, LD_IND, and tail_call() can all cause it to return prematurely.

When such a function is called by another BPF function, the verifier doesn't take this into account when calculating the bounds of r0 in the caller after the callee returns.

---
Changes in v2:
- Handle LD_ABS and LD_IND, not just tail_call()
- Split tests out
- Use inline asm for tests

---
Arthur Fabre (2):
bpf: Don't trust r0 bounds after BPF to BPF calls with abnormal
returns
selftests/bpf: Test r0 bounds after BPF to BPF call with abnormal
return

 kernel/bpf/verifier.c                         | 18 ++--
 .../selftests/bpf/prog_tests/verifier.c       |  2 +
 .../bpf/progs/verifier_abnormal_ret.c         | 88 +++++++++++++++++++
 3 files changed, 102 insertions(+), 6 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_abnormal_ret.c
Signature · 1 line
2.34.1