Skip to content

bpf: Reduce verifier stack frame size #9246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: bpf: Reduce verifier stack frame size
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=978313

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 564606f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978313
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 38d95be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978313
version: 2

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the series/978313=>bpf-next branch from f9cf02f to ad47714 Compare July 2, 2025 18:47
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 38d95be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978313
version: 2

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the series/978313=>bpf-next branch from ad47714 to 6e34678 Compare July 2, 2025 19:01
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 38d95be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978313
version: 2

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the series/978313=>bpf-next branch from 6e34678 to eff30a1 Compare July 2, 2025 19:08
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 38d95be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978313
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 38d95be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978313
version: 2

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the series/978313=>bpf-next branch from 6d49e2e to 279f98e Compare July 2, 2025 21:13
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 38d95be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978662
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 1f24c0d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=978662
version: 3

Yonghong Song added 3 commits July 3, 2025 15:30
In verifier.c, the following code patterns (in two places)
  struct bpf_insn *patch = &insn_buf[0];
can be simplified to
  struct bpf_insn *patch = insn_buf;
which is easier to understand.

Acked-by: Eduard Zingerman <[email protected]>
Signed-off-by: Yonghong Song <[email protected]>
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]

Use env->insn_buf for bpf insns instead of putting these insns on the
stack. This can resolve the above 'bpf_check' error. The 'do_check' error
will be resolved in the next patch.

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

Reported-by: Arnd Bergmann <[email protected]>
Tested-by: Arnd Bergmann <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Acked-by: Eduard Zingerman <[email protected]>
Signed-off-by: Yonghong Song <[email protected]>
Add a 'struct bpf_scc_callchain callchain_buf' field in bpf_verifier_env.
This way, the previous bpf_scc_callchain local variables can be
replaced by taking address of env->callchain_buf. This can reduce stack
usage and fix the following error:
    kernel/bpf/verifier.c:19921:12: error: stack frame size (1368) exceeds limit (1280) in 'do_check'
        [-Werror,-Wframe-larger-than]

Reported-by: Arnd Bergmann <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Acked-by: Eduard Zingerman <[email protected]>
Signed-off-by: Yonghong Song <[email protected]>
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the series/978313=>bpf-next branch from a5beedc to dbc3d1d Compare July 3, 2025 22:30
@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=978662 irrelevant now. Closing PR.

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot deleted the series/978313=>bpf-next branch July 4, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants