Skip to content

bpf: Reduce verifier stack frame size

Yonghong Song bpf 2 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. v3 Latest3 patches 0 repliesApplied 3/3
  2. v23 patches 5 repliesSuperseded

Changes in v3 from the cover letter

- v2: https://lore.kernel.org/bpf/[email protected]/
- Rename env->callchain to env->callchain_buf so it is clear that
- env->callchain_buf is used for a temp buf.

Patches in v3 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf: Simplify assignment to struct bpf_insn pointer in do_misc_fixups()kernel/bpf/verifier.c+2 -20 repliesApplied
2/3bpf: Reduce stack frame size by using env->insn_buf for bpf insnskernel/bpf/verifier.c+92 -980 repliesApplied
3/3bpf: Avoid putting struct bpf_scc_callchain variables on the stackinclude/linux/bpf_verifier.h kernel/bpf/verifier.c+19 -180 repliesApplied

Reviews trailers per patch

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

PatchEduard ZingermanArnd BergmannJiri Olsa
1/3A-b
2/3A-b T-b A-b
3/3A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/3] bpf: Reduce verifier stack frame size

Arnd Bergmann reported an issue ([1]) where clang compiler (less than
llvm18) may trigger an error where the stack frame size exceeds the limit.
I can reproduce the error like below:
kernel/bpf/verifier.c:24491:5: error: stack frame size (2552) exceeds limit (1280) in 'bpf_check'
[-Werror,-Wframe-larger-than]
kernel/bpf/verifier.c:19921:12: error: stack frame size (1368) exceeds limit (1280) in 'do_check'
[-Werror,-Wframe-larger-than]

This patch series fixed the above two errors by reducing stack size. See each individual patches for details.

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

Changelogs:
v2 -> v3:
- v2: https://lore.kernel.org/bpf/[email protected]/
- Rename env->callchain to env->callchain_buf so it is clear that
- env->callchain_buf is used for a temp buf.

v1 -> v2:
- v1: https://lore.kernel.org/bpf/[email protected]/
- Simplify assignment to struct bpf_insn pointer in do_misc_fixups().
- Restore original implementation in opt_hard_wire_dead_code_branches() as only one insn on the stack.
- Avoid unnecessary insns for 64bit modulo (mod 0/-1) operations.

Yonghong Song (3):
bpf: Simplify assignment to struct bpf_insn pointer in
do_misc_fixups()
bpf: Reduce stack frame size by using env->insn_buf for bpf insns
bpf: Avoid putting struct bpf_scc_callchain variables on the stack

 include/linux/bpf_verifier.h |   1 +
 kernel/bpf/verifier.c        | 230 +++++++++++++++++------------------
 2 files changed, 113 insertions(+), 118 deletions(-)
Signature · 1 line
2.47.1