Skip to content

Fix acyclic ownership checks

Kumar Kartikeya Dwivedi bpf 2 versions – Applied

Status from this message: This series was applied to bpf/bpf.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesApplied 2/2
  2. v13 patches 1 replySuperseded

Changes in v2 from the cover letter

v1: https://lore.kernel.org/bpf/[email protected]/

* Fold the graph-walk and local-kptr changes into one complete fix. (Alexei)
* Explain why the original rule catches graph-only cycles, its three-type chain bound, and the missing local-kptr ownership edges. (Alexei)
* Distinguish synchronous recursive field destruction from the deferred RCU freeing of object storage.
* Add depth-boundary tests with child-first BTF ordering and a shared suffix reached with different remaining budgets.
* Cover list and rbtree chains at the original three-type bound and at the new eight-type bound, including rejected over-limit cases.

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Bound ownership depth through local kptrs and graph rootskernel/bpf/btf.c tools/testing/selftests/bpf/prog_tests/linked_list.c+88 -500 repliesApplied
2/2selftests/bpf: Check local object ownership depthtools/testing/selftests/bpf/prog_tests/local_kptr_ownership.c+296 -00 repliesApplied

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH bpf-next v2 0/2] Fix acyclic ownership checks

Bound and ensure acyclic ownership graphs for native data structures to fix a bug reported by Nicholas. See commit logs and tests for details.

The existing list/rbtree rule already rejects graph-only cycles and bounds those chains conservatively. It misses ownership through local referenced kptrs, which can produce unbounded synchronous field destruction. Validate all local ownership edges together, with an explicit depth bound, and allow longer acyclic graph-only layouts within that bound.

Changelog:
----------
v1 -> v2
v1: https://lore.kernel.org/bpf/[email protected]/

* Fold the graph-walk and local-kptr changes into one complete fix. (Alexei)
* Explain why the original rule catches graph-only cycles, its three-type chain bound, and the missing local-kptr ownership edges. (Alexei)
* Distinguish synchronous recursive field destruction from the deferred RCU freeing of object storage.
* Add depth-boundary tests with child-first BTF ordering and a shared suffix reached with different remaining budgets.
* Cover list and rbtree chains at the original three-type bound and at the new eight-type bound, including rejected over-limit cases.

Kumar Kartikeya Dwivedi (2):
bpf: Bound ownership depth through local kptrs and graph roots selftests/bpf: Check local object ownership depth

 kernel/bpf/btf.c                              | 134 +++++---
 .../selftests/bpf/prog_tests/linked_list.c    |   4 +-
 .../bpf/prog_tests/local_kptr_ownership.c     | 296 ++++++++++++++++++
 3 files changed, 384 insertions(+), 50 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/local_kptr_ownership.c

base-commit: a41c69c6ea14596cfd95978483166d4eff52435e

Signature · 1 line
2.53.0