Skip to content

bpf: Relax 8 frame limitation for global subprogs

Emil Tsalapatis bpf 4 versions – 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 · linked by author and title

  1. v6 Latest2 patches 1 replyApplied 2/2
  2. v52 patches 3 repliesSuperseded
  3. v42 patches 4 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v32 patches8 repliesSuperseded

Patches in v6 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Only enforce 8 frame call stack limit for all-static stackskernel/bpf/verifier.c tools/testing/selftests/bpf/progs/test_global_func3.c+63 -311 replyApplied
2/2selftests/bpf: Add deep call stack selfteststools/testing/selftests/bpf/prog_tests/test_global_funcs.c tools/testing/selftests/bpf/progs/test_global_func_deep_stack.c+97 -00 repliesApplied

Reviews trailers per patch

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

PatchMykyta YatsenkoEduard Zingerman
1/2A-b A-b
2/2A-b

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

Read the v6 thread

Cover letter [PATCH bpf-next v6 0/2] bpf: Relax 8 frame limitation for global subprogs

The BPF verifier currently limits the maximum runtime call stack to 8 frames. Larger BPF programs like sched-ext schedulers routinely fail verification because they exceed this limit, even as they use very little actual stack space for each frame.

Relax the verifier to permit call stacks > 8 frames deep when the call stacks include global subprogs. The old 8 stack frame limit now only applies to call stacks composed entirely of static function calls. This works because global functions are each verified in isolation, so the verifier does not need to cross-reference verification state across the function call boundary, which has been the reason for limiting the call stack size in the first place.

This patch does not change the verification time limit of 8 stack frames. Static functions that are inlined for verification purposes still only go 8 frames deep to avoid changing the verifier's internal data structures used for verification. These data structures only support holding information on up to 8 stack frames.

This patch also does not adjust the actual maximum stack size of 512.

CHANGELOG
=========

v5 -> v6 (https://lore.kernel.org/bpf/[email protected]/)
- Make bpf_subprog_call_depth_info internal to verifier.c (Alexei)

v4 -> v5 (https://lore.kernel.org/bpf/[email protected]/)
- Move depth tracking state to verifier (Eduard) and free it after verification (Alexei)
- Fix selftest patch title and formatting errors (Yonghong)

v3 -> v4 (https://lore.kernel.org/bpf/[email protected]/)
- Factor out temp call depth tracking info into its own struct (Eduard)
- Bring depth calculation loop in line with the other instances (Mykyta)
- Add comment on why selftest call stack is 16 bytes/frame (Eduard)
- Rename "cidx" to "caller" for clarity (Mykyta, Eduard)

v2 -> v3 (https://lore.kernel.org/bpf/[email protected]/)
- Change logic to remove arbitrary limit on call depth (Eduard)
- Add additional selftests (Eduard)

v1 -> v2 (https://lore.kernel.org/bpf/[email protected])
- Adjust patch to only increase the runtime stack depth, leaving the verification-time stack depth unchanged (Alexei)

Emil Tsalapatis (2):
bpf: Only enforce 8 frame call stack limit for all-static stacks selftests/bpf: Add deep call stack selftests

 kernel/bpf/verifier.c                         | 76 ++++++++++-----
 .../bpf/prog_tests/test_global_funcs.c        |  2 +
 .../selftests/bpf/progs/test_global_func3.c   | 18 ++--
 .../bpf/progs/test_global_func_deep_stack.c   | 95 +++++++++++++++++++
 4 files changed, 160 insertions(+), 31 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_global_func_deep_stack.c
Signature · 1 line
2.49.0