Skip to content

bpf: Account for early exit of bpf_tail_call() and LD_ABS

Arthur Fabre bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 Latest2 patches 4 repliesIn review

Changes in v3 from the cover letter

- Don't handle just r0, model abnormal exits as a branch that exits or falls through.
- Try to use C as much as possible for the tests.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Account for early exit of bpf_tail_call() and LD_ABSkernel/bpf/verifier.c+61 -232 replies
2/2selftests/bpf: Test r0 and ref lifetime after BPF-BPF call with abnormal returntools/testing/selftests/bpf/prog_tests/verifier.c tools/testing/selftests/bpf/progs/verifier_abnormal_ret.c+117 -02 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 v3 thread

Cover letter [PATCH bpf v3 0/2] bpf: Account for early exit of bpf_tail_call() and LD_ABS

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

When such a function is called by another BPF function, the verifier doesn't take this into account when calculating the bounds of the return value, or pointers to the caller's stack.

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

Changes in v3:
- Don't handle just r0, model abnormal exits as a branch that exits or falls through.
- Try to use C as much as possible for the tests.

Arthur Fabre (2):
bpf: Account for early exit of bpf_tail_call() and LD_ABS selftests/bpf: Test r0 and ref lifetime after BPF-BPF call with
abnormal return

 kernel/bpf/verifier.c                         |  84 +++++++++----
 .../selftests/bpf/prog_tests/verifier.c       |   2 +
 .../bpf/progs/verifier_abnormal_ret.c         | 115 ++++++++++++++++++
 3 files changed, 178 insertions(+), 23 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_abnormal_ret.c
Signature · 1 line
2.43.0