From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: <bot+bpf-ci@kernel.org>, <bpf@vger.kernel.org>
Cc: <ast@kernel.org>, <andrii@kernel.org>, <daniel@iogearbox.net>,
<eddyz87@gmail.com>, <emil@etsalapatis.com>, <tj@kernel.org>,
<kkd@meta.com>, <kernel-team@meta.com>, <martin.lau@kernel.org>,
<yonghong.song@linux.dev>, <mason@kernel.org>,
<ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf-next v1 16/18] bpf, x86: Allow programs 2 KiB of stack
Date: Wed, 23 Sep 2026 22:28:09 +0200 [thread overview]
Message-ID: <DLMZ9MMDZU1Y.2MHD1XVK8OTAB@gmail.com> (raw)
In-Reply-To: <da4e6f7d608df34719ae1c05ec5da4da9f53e42adfde8e80d653ef0017c3bf47@mail.kernel.org>
On Wed Sep 23, 2026 at 10:12 PM CEST, bot+bpf-ci wrote:
>> diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst
>> index eb19c945f4d5..be5fc4ac00d6 100644
>> --- a/Documentation/bpf/bpf_design_QA.rst
>> +++ b/Documentation/bpf/bpf_design_QA.rst
>> @@ -221,9 +221,13 @@ newer kernels. BPF programs need to change accordingly when this happens.
>>
>> Q: How much stack space a BPF program uses?
>> -------------------------------------------
>> -A: Currently all program types are limited to 512 bytes of stack
>> -space, but the verifier computes the actual amount of stack used
>> -and both interpreter and most JITed code consume necessary amount.
>> +A: A program may use up to 2 KiB of stack, combined over its call
>> +chain, when the JIT of the architecture reports support for large
>> +stacks (currently x86-64); a single function may use all of it, and
>> +every frame of a program running on a private stack gets the whole
>> +amount. Elsewhere, and whenever the interpreter is used, the limit is
>> +512 bytes. The verifier computes the actual amount of stack used and
>> +both interpreter and most JITed code consume necessary amount.
>
> Is the interpreter limit stated correctly here? The text says "whenever
> the interpreter is used, the limit is 512 bytes" in a paragraph where
> 2 KiB is defined as combined over the call chain.
>
> When bpf_jit_supports_large_stack() returns true, a program with
> jit_requested set is verified against MAX_BPF_STACK_JIT (2048) in
> bpf_check() via env->stack_limit = bpf_prog_stack_limit(env->prog), and
> check_max_stack_depth_subprog() bounds the combined depth of the call chain
> by that limit.
>
> If JIT compilation then fails with anything other than -EFAULT (for example,
> a subprogram not being jited returns -ENOTSUPP in bpf_jit_subprogs(), or an
> allocation failure during blinding occurs) and CONFIG_BPF_JIT_ALWAYS_ON is
> not set, bpf_jit_subprogs() restores the instructions, clears
> prog->jit_requested, and bpf_fixup_call_args() falls back to the
> interpreter. The interpreter checks on that path are per frame in
> bpf_patch_call_args():
>
> int bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth)
> {
> stack_depth = max_t(u32, stack_depth, 1);
> /* Prevent out-of-bounds read to interpreters_args */
> if (stack_depth > MAX_BPF_STACK)
> return -EINVAL;
>
> and bpf_prog_select_interpreter() for the main frame.
>
> A chain of four subprograms each using 512 bytes (2048 combined) would be
> accepted by the verifier and run in the interpreter, whereas before this
> patch the combined chain was capped at 512. Each interpreter frame has its
> own stack array, so this is not an out-of-bounds access. Should the text
> clarify that the interpreter's 512 byte limit applies per function, or
> should the fallback path reject a chain whose combined depth exceeds
> MAX_BPF_STACK?
>
It is indeed slightly confusnig, will reword.
> [ ... ]
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/35909853278
next prev parent reply other threads:[~2026-09-23 20:28 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 19:11 [PATCH bpf-next v1 00/18] Raise BPF program stack size to 2KiB Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 01/18] bpf: Add accessors for verifier stack slots Kumar Kartikeya Dwivedi
2026-09-23 19:57 ` bot+bpf-ci
2026-09-23 20:04 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 02/18] bpf: Widen the stack slot index in the jump history Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 03/18] bpf: Store linked registers in the jump history as an array Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 04/18] bpf: Track backtracking stack slots with bitmaps Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 05/18] bpf: Track scratched stack slots with a bitmap Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 06/18] bpf: Treat unknown-size stack reads as reaching the frame top Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 07/18] bpf: Size liveness stack masks by the stack each frame uses Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 08/18] bpf: Grow the verifier id scratch on demand Kumar Kartikeya Dwivedi
2026-09-23 19:24 ` sashiko-bot
2026-09-23 19:29 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 09/18] selftests/bpf: Cover the tail call caller stack depth limit Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 10/18] selftests/bpf: Check that narrow stack stores define no slot Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 11/18] selftests/bpf: Check liveness merge of masks with different widths Kumar Kartikeya Dwivedi
2026-09-23 19:26 ` sashiko-bot
2026-09-23 19:29 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 12/18] bpf: Size the per-frame verifier structures for a 2 KiB stack Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:27 ` Kumar Kartikeya Dwivedi
2026-09-23 22:55 ` Alexei Starovoitov
2026-09-23 19:11 ` [PATCH bpf-next v1 13/18] bpf: Bound program stack use by a per-program limit Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 14/18] selftests/bpf: Add load conditions on the program stack limit Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:27 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 15/18] selftests/bpf: Give the 512-byte stack boundary tests a 2 KiB twin Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 16/18] bpf, x86: Allow programs 2 KiB of stack Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:28 ` Kumar Kartikeya Dwivedi [this message]
2026-09-23 19:11 ` [PATCH bpf-next v1 17/18] bpf, arm64: " Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 18/18] selftests/bpf: Test the 2 KiB stack budget Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:28 ` Kumar Kartikeya Dwivedi
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=DLMZ9MMDZU1Y.2MHD1XVK8OTAB@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
--cc=tj@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.