Skip to content

Fix resource leak checks for tail calls

Kumar Kartikeya Dwivedi bpf 1 version Applied

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

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesApplied 3/3

Patches in v1 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf: Tighten tail call checks for lingering locks, RCU, preempt_disablekernel/bpf/verifier.c+15 -00 repliesApplied
2/3bpf: Unify resource leak checkskernel/bpf/verifier.c tools/testing/selftests/bpf/progs/exceptions_fail.c tools/testing/selftests/bpf/progs/preempt_lock.c +2 more+46 -680 repliesApplied
3/3selftests/bpf: Add tests for tail calls with locks and refstools/testing/selftests/bpf/prog_tests/tailcalls.c tools/testing/selftests/bpf/progs/tailcall_fail.c+72 -00 repliesApplied

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH bpf-next v1 0/3] Fix resource leak checks for tail calls

This set contains a fix for detecting unreleased RCU read locks or unfinished preempt_disable sections when performing a tail call. Spin locks are prevented by accident since they don't allow any function calls, including tail calls (modelled as call instruction to a helper), so we ensure they are checked as well, in preparation for relaxing function call restricton for critical sections in the future.

Then, in the second patch, all the checks for reference leaks and locks are unified into a single function that can be called from different places. This unification patch is kept separate and placed after the fix to allow independent backport of the fix to older kernels without a depdendency on the clean up.

Naturally, this creates a divergence in the disparate error messages, therefore selftests that rely on the exact error strings need to be updated to match the new verifier log message.

A selftest is included to ensure no regressions occur wrt this behavior.

Kumar Kartikeya Dwivedi (3):
bpf: Tighten tail call checks for lingering locks, RCU,
preempt_disable
bpf: Unify resource leak checks
selftests/bpf: Add tests for tail calls with locks and refs

 kernel/bpf/verifier.c                         | 75 +++++++++----------
 .../selftests/bpf/prog_tests/tailcalls.c      |  8 ++
 .../selftests/bpf/progs/exceptions_fail.c     |  4 +-
 .../selftests/bpf/progs/preempt_lock.c        | 14 ++--
 .../selftests/bpf/progs/tailcall_fail.c       | 64 ++++++++++++++++
 .../bpf/progs/verifier_ref_tracking.c         |  4 +-
 .../selftests/bpf/progs/verifier_spin_lock.c  |  2 +-
 7 files changed, 118 insertions(+), 53 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/tailcall_fail.c

base-commit: 77017b9c46820d72596e50a3986bd0734c1340a9

Signature · 1 line
2.43.5