From: Yonghong Song <yonghong.song@linux.dev>
To: Eduard Zingerman <eddyz87@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>,
Arnd Bergmann <arnd@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH bpf-next v2 2/3] bpf: Reduce stack frame size by using env->insn_buf for bpf insns
Date: Wed, 2 Jul 2025 19:02:58 -0700 [thread overview]
Message-ID: <0003e790-c835-4f38-9cea-4f66fb39d3f2@linux.dev> (raw)
In-Reply-To: <3f7f3c4f80d0deb51432b098f5ae30d5c68de085.camel@gmail.com>
On 7/2/25 1:33 PM, Eduard Zingerman wrote:
> On Wed, 2025-07-02 at 10:11 -0700, Yonghong Song wrote:
>> 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/20250620113846.3950478-1-arnd@kernel.org/
>>
>> Reported-by: Arnd Bergmann <arnd@kernel.org>
>> Tested-by: Arnd Bergmann <arnd@arndb.de>
>> Acked-by: Jiri Olsa <jolsa@kernel.org>
>> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
>> ---
> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
>
>> kernel/bpf/verifier.c | 189 ++++++++++++++++++++----------------------
>> 1 file changed, 91 insertions(+), 98 deletions(-)
>>
>> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
>> index 8b0a25851089..ef53e313d841 100644
>> --- a/kernel/bpf/verifier.c
>> +++ b/kernel/bpf/verifier.c
>> @@ -21010,7 +21010,9 @@ static int opt_remove_nops(struct bpf_verifier_env *env)
>> static int opt_subreg_zext_lo32_rnd_hi32(struct bpf_verifier_env *env,
>> const union bpf_attr *attr)
>> {
>> - struct bpf_insn *patch, zext_patch[2], rnd_hi32_patch[4];
>> + struct bpf_insn *patch;
>> + struct bpf_insn *zext_patch = env->insn_buf;
>> + struct bpf_insn *rnd_hi32_patch = &env->insn_buf[2];
> Nit: I'd add a comment here, something along the lines:
> "use env->insn_buf as two independent buffers"
Ack. Sounds a good idea.
>
>> struct bpf_insn_aux_data *aux = env->insn_aux_data;
>> int i, patch_len, delta = 0, len = env->prog->len;
>> struct bpf_insn *insns = env->prog->insnsi;
> [...]
next prev parent reply other threads:[~2025-07-03 2:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 17:11 [PATCH bpf-next v2 0/3] bpf: Reduce verifier stack frame size Yonghong Song
2025-07-02 17:11 ` [PATCH bpf-next v2 1/3] bpf: Simplify assignment to struct bpf_insn pointer in do_misc_fixups() Yonghong Song
2025-07-02 18:58 ` Eduard Zingerman
2025-07-02 17:11 ` [PATCH bpf-next v2 2/3] bpf: Reduce stack frame size by using env->insn_buf for bpf insns Yonghong Song
2025-07-02 20:33 ` Eduard Zingerman
2025-07-03 2:02 ` Yonghong Song [this message]
2025-07-02 17:11 ` [PATCH bpf-next v2 3/3] bpf: Avoid putting struct bpf_scc_callchain variables on the stack Yonghong Song
2025-07-02 19:03 ` Eduard Zingerman
2025-07-03 2:01 ` Yonghong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0003e790-c835-4f38-9cea-4f66fb39d3f2@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox