From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Emil Tsalapatis <emil@etsalapatis.com>,
kkd@meta.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v4 15/16] bpf: Report Verifier Limit errors
Date: Thu, 13 Aug 2026 13:34:51 -0700 [thread overview]
Message-ID: <9baab2473b734a0c75e2d49202e3b46adf5b22e1.camel@gmail.com> (raw)
In-Reply-To: <20260812233326.3575958-16-memxor@gmail.com>
On Thu, 2026-08-13 at 01:33 +0200, Kumar Kartikeya Dwivedi wrote:
...
> diff --git a/kernel/bpf/liveness.c b/kernel/bpf/liveness.c
> index 1c997aeba6fa..f39f01637ac0 100644
> --- a/kernel/bpf/liveness.c
> +++ b/kernel/bpf/liveness.c
> @@ -8,6 +8,8 @@
> #include <linux/slab.h>
> #include <linux/sort.h>
>
> +#include "diagnostics.h"
> +
> #define verbose(env, fmt, args...) bpf_verifier_log_write(env, fmt, ##args)
>
> struct per_frame_masks {
> @@ -1856,6 +1858,10 @@ static int analyze_subprog(struct bpf_verifier_env *env,
> if (++env->liveness->subprog_calls > 10000) {
> verbose(env, "liveness analysis exceeded complexity limit (%d calls)\n",
> env->liveness->subprog_calls);
> + bpf_diag_limit(
> + env, start, "liveness analysis complexity",
> + "Reduce the number of distinct call paths or argument patterns reaching these subprograms.",
Nit: "these subprograms" is not very clear here, drop it?
> + "The verifier recomputed subprogram liveness too many times while tracking stack and register reads across call paths");
Nit: it's not a "subprogram liveness" ->
"Stack liveness analysis failed to reach a fixed point after %d iterations".
> return -E2BIG;
> }
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 8e5319f47ccb..a14315d19866 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -5252,6 +5252,38 @@ struct bpf_subprog_call_depth_info {
> int frame; /* # of consecutive static call stack frames on top of stack */
> };
>
> +static const char *bpf_diag_append_subprog_chain(struct bpf_verifier_env *env,
> + const char *chain, int subprog)
> +{
> + const char *prefix = chain && *chain ? " -> " : "";
> + const char *name = bpf_subprog_name(env, subprog);
> + const char *old = chain ?: "";
> +
> + if (name && *name)
> + return bpf_diag_fmt(env, "%s%s%s", old, prefix, name);
> + return bpf_diag_fmt(env, "%s%ssubprogram %d", old, prefix, subprog);
> +}
> +
> +static const char *bpf_diag_alloc_subprog_call_chain(struct bpf_verifier_env *env,
> + struct bpf_subprog_call_depth_info *dinfo,
> + int idx)
Nit: drop the 'bpf_diag_' prefix.
> +{
> + int call_chain[MAX_CALL_FRAMES + 1];
> + int i, subprog, cnt = 0;
> + const char *chain = NULL;
> +
> + for (subprog = idx; subprog >= 0 && cnt < ARRAY_SIZE(call_chain);
> + subprog = dinfo[subprog].caller)
> + call_chain[cnt++] = subprog;
> +
> + if (subprog >= 0)
> + chain = "...";
> + for (i = cnt - 1; i >= 0; i--)
> + chain = bpf_diag_append_subprog_chain(env, chain, call_chain[i]);
> +
> + return chain;
> +}
> +
> /* starting from main bpf function walk all instructions of the function
> * and recursively walk all callees that given function can call.
> * Ignore jump and exit insns.
> @@ -5294,9 +5326,17 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx,
> * of caller's stack as shown on the example above.
> */
> if (idx && subprog[idx].has_tail_call && depth >= 256) {
> + const char *chain = bpf_diag_alloc_subprog_call_chain(env, dinfo, idx);
Nit: bubble up `chain` definition to the top of the function.
> +
> verbose(env,
> "tail_calls are not allowed when call stack of previous frames is %d bytes. Too large\n",
> depth);
> + bpf_diag_limit(
> + env, subprog[idx].start, "call stack with tail calls",
"call stack with tail calls" -> "stack depth at tail call"
> + "Reduce stack usage in caller frames, or avoid combining deep bpf2bpf calls with tail calls.",
> + "Call chain %s reaches a subprogram with tail calls after caller frames already use %d bytes; "
> + "tail-call paths are limited to 256 bytes in caller frames",
> + chain ?: "the current call chain", depth);
"the current call chain" is useless, if it's a guard for ENOMEM,
let's make it "<can't render callchain>".
> return -EACCES;
> }
>
...
next prev parent reply other threads:[~2026-08-13 20:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 23:33 [PATCH bpf-next v4 00/16] Redesign Verification Errors Kumar Kartikeya Dwivedi
2026-08-12 23:33 ` [PATCH bpf-next v4 01/16] bpf: Add verifier diagnostics report helpers Kumar Kartikeya Dwivedi
2026-08-12 23:41 ` sashiko-bot
2026-08-13 18:46 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 02/16] bpf: Add source and instruction diagnostic context Kumar Kartikeya Dwivedi
2026-08-13 0:15 ` sashiko-bot
2026-08-13 18:46 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 03/16] bpf: Add verifier diagnostic event log Kumar Kartikeya Dwivedi
2026-08-13 18:45 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 04/16] bpf: Prune verifier diagnostics when switching paths Kumar Kartikeya Dwivedi
2026-08-13 18:34 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 05/16] bpf: Track verifier register diagnostic events Kumar Kartikeya Dwivedi
2026-08-12 23:53 ` sashiko-bot
2026-08-13 19:44 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 06/16] bpf: Track verifier reference " Kumar Kartikeya Dwivedi
2026-08-12 23:33 ` [PATCH bpf-next v4 07/16] bpf: Track verifier context " Kumar Kartikeya Dwivedi
2026-08-12 23:33 ` [PATCH bpf-next v4 08/16] bpf: Report Register Type Safety errors Kumar Kartikeya Dwivedi
2026-08-12 23:33 ` [PATCH bpf-next v4 09/16] bpf: Report Memory Safety bounds errors Kumar Kartikeya Dwivedi
2026-08-13 19:52 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 10/16] bpf: Report Resource Lifetime reference leaks Kumar Kartikeya Dwivedi
2026-08-13 19:59 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 11/16] bpf: Report Call Type Safety argument errors Kumar Kartikeya Dwivedi
2026-08-12 23:58 ` sashiko-bot
2026-08-12 23:33 ` [PATCH bpf-next v4 12/16] bpf: Report Execution Context Safety errors Kumar Kartikeya Dwivedi
2026-08-13 20:12 ` Eduard Zingerman
2026-08-12 23:33 ` [PATCH bpf-next v4 13/16] bpf: Report Program Structure CFG errors Kumar Kartikeya Dwivedi
2026-08-12 23:33 ` [PATCH bpf-next v4 14/16] bpf: Report Policy helper and kfunc errors Kumar Kartikeya Dwivedi
2026-08-12 23:33 ` [PATCH bpf-next v4 15/16] bpf: Report Verifier Limit errors Kumar Kartikeya Dwivedi
2026-08-13 20:34 ` Eduard Zingerman [this message]
2026-08-12 23:33 ` [PATCH bpf-next v4 16/16] bpf: Gate verifier diagnostics on log level Kumar Kartikeya Dwivedi
2026-08-13 20:38 ` Eduard Zingerman
2026-08-13 1:38 ` [PATCH bpf-next v4 00/16] Redesign Verification Errors Eduard Zingerman
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=9baab2473b734a0c75e2d49202e3b46adf5b22e1.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=memxor@gmail.com \
/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.