BPF List
 help / color / mirror / Atom feed
* [PATCH bpf v3 0/2] bpf: Account for early exit of bpf_tail_call() and LD_ABS
@ 2025-01-06 17:15 Arthur Fabre
  2025-01-06 17:15 ` [PATCH bpf v3 1/2] " Arthur Fabre
  2025-01-06 17:15 ` [PATCH bpf v3 2/2] selftests/bpf: Test r0 and ref lifetime after BPF-BPF call with abnormal return Arthur Fabre
  0 siblings, 2 replies; 7+ messages in thread
From: Arthur Fabre @ 2025-01-06 17:15 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	kernel-team, Arthur Fabre

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

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-08 20:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 17:15 [PATCH bpf v3 0/2] bpf: Account for early exit of bpf_tail_call() and LD_ABS Arthur Fabre
2025-01-06 17:15 ` [PATCH bpf v3 1/2] " Arthur Fabre
2025-01-06 20:31   ` Eduard Zingerman
2025-01-08 20:44     ` Arthur Fabre
2025-01-06 17:15 ` [PATCH bpf v3 2/2] selftests/bpf: Test r0 and ref lifetime after BPF-BPF call with abnormal return Arthur Fabre
2025-01-06 20:34   ` Eduard Zingerman
2025-01-08 20:46     ` Arthur Fabre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox