On 7/2/25 12:03 PM, Eduard Zingerman wrote:
On Wed, 2025-07-02 at 10:11 -0700, Yonghong Song wrote:
Add a 'struct bpf_scc_callchain callchain' field in bpf_verifier_env.
This way, the previous bpf_scc_callchain local variables can be
replaced by taking address of env->callchain. 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 <arnd@xxxxxxxxxx>
Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Signed-off-by: Yonghong Song <yonghong.song@xxxxxxxxx>
---
Oh, well.
I liked stack allocation for callchain object, because it emphasized
its ephemeral by-value status.
The changes lgtm, all places with callchain stack allocation replaced.
Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
[...]
include/linux/bpf_verifier.h | 1 +
kernel/bpf/verifier.c | 36 ++++++++++++++++++------------------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 7e459e839f8b..e2c175d608bb 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -841,6 +841,7 @@ struct bpf_verifier_env {
char tmp_str_buf[TMP_STR_BUF_LEN];
struct bpf_insn insn_buf[INSN_BUF_SIZE];
struct bpf_insn epilogue_buf[INSN_BUF_SIZE];
+ struct bpf_scc_callchain callchain;
Nit: maybe a comment here about this being a scratch buffer?
Maybe I can just change the variable name from 'callchain'
to 'callchain_buf' so it will be clear it is a scratch buffer?
/* array of pointers to bpf_scc_info indexed by SCC id */
struct bpf_scc_info **scc_info;
u32 scc_cnt;
[...]