From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Eduard Zingerman" <eddyz87@gmail.com>,
"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 v3 13/17] bpf: Report Program Structure CFG errors
Date: Wed, 15 Jul 2026 09:37:01 +0200 [thread overview]
Message-ID: <DJYZ12G29BZ8.2JBXPFCGEQGJL@gmail.com> (raw)
In-Reply-To: <9d9ec72059ef2855c3e2a47982e44cff9dd1165a.camel@gmail.com>
On Tue Jul 14, 2026 at 10:00 PM CEST, Eduard Zingerman wrote:
> On Mon, 2026-07-13 at 17:39 +0200, Kumar Kartikeya Dwivedi wrote:
>> Augment selected subprogram CFG validation failures with Program Structure
>> reports. These errors are structural rather than path-dependent, so the report
>> focuses on source and instruction context instead of causal history.
>>
>> Cover jumps that leave the current subprogram, subprograms whose last
>> instruction can fall through into the next subprogram, and recursive bpf2bpf
>> call graph edges.
>>
>> Format long jump-range reasons directly in diagnostics.c, and keep the
>> fallthrough suggestion aligned with the verifier check by suggesting exit or
>> explicit jumps.
>>
>> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
>> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>> ---
>> kernel/bpf/cfg.c | 55 ++++++++++++++++++++++++++++++++++++++++
>> kernel/bpf/diagnostics.c | 19 ++++++++++++++
>> kernel/bpf/diagnostics.h | 3 +++
>> kernel/bpf/verifier.c | 32 +++++++++++++++++++++++
>> 4 files changed, 109 insertions(+)
>>
>> diff --git a/kernel/bpf/cfg.c b/kernel/bpf/cfg.c
>> index 26d37066465f..376f6b6d469c 100644
>> --- a/kernel/bpf/cfg.c
>> +++ b/kernel/bpf/cfg.c
>> @@ -5,6 +5,8 @@
>> #include <linux/filter.h>
>> #include <linux/sort.h>
>>
>> +#include "diagnostics.h"
>> +
>> #define verbose(env, fmt, args...) bpf_verifier_log_write(env, fmt, ##args)
>>
>> /* non-recursive DFS pseudo code
>> @@ -113,6 +115,12 @@ static int push_insn(int t, int w, int e, struct bpf_verifier_env *env)
>> if (w < 0 || w >= env->prog->len) {
>> verbose_linfo(env, t, "%d: ", t);
>> verbose(env, "jump out of range from insn %d to %d\n", t, w);
>> + bpf_diag_report_program_structure(env, t, "jump out of range",
>> + "Keep branch targets inside the program.",
>> + "Instruction %d jumps to instruction %d, but the "
>> + "program only contains instructions 0 through "
>> + "%d.",
>> + t, w, env->prog->len - 1);
>
> Nit: I'd forgo the formatting rules and just write the above like:
>
> bpf_diag_report_program_structure(
> env, t, "jump out of range",
> "Keep branch targets inside the program.",
> "Instruction %d jumps to instruction %d, but the program only contains instructions 0 through %d.",
> t, w, env->prog->len - 1);
>
> Easier to read and easier to grep.
>
>> return -EINVAL;
>> }
>>
>
Ack, will change throughout the series.
> [...]
next prev parent reply other threads:[~2026-07-15 7:37 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 15:38 [PATCH bpf-next v3 00/17] Redesign Verification Errors Kumar Kartikeya Dwivedi
2026-07-13 15:38 ` [PATCH bpf-next v3 01/17] bpf: Add verifier diagnostics report helpers Kumar Kartikeya Dwivedi
2026-07-13 15:50 ` sashiko-bot
2026-07-13 15:38 ` [PATCH bpf-next v3 02/17] bpf: Add source and instruction diagnostic context Kumar Kartikeya Dwivedi
2026-07-13 15:38 ` [PATCH bpf-next v3 03/17] bpf: Add verifier diagnostic event log Kumar Kartikeya Dwivedi
2026-07-13 15:54 ` sashiko-bot
2026-07-13 15:38 ` [PATCH bpf-next v3 04/17] bpf: Prune verifier diagnostics when switching paths Kumar Kartikeya Dwivedi
2026-07-13 16:02 ` sashiko-bot
2026-07-13 15:38 ` [PATCH bpf-next v3 05/17] bpf: Track verifier register diagnostic events Kumar Kartikeya Dwivedi
2026-07-13 16:06 ` sashiko-bot
2026-07-13 15:38 ` [PATCH bpf-next v3 06/17] bpf: Track verifier reference " Kumar Kartikeya Dwivedi
2026-07-13 15:38 ` [PATCH bpf-next v3 07/17] bpf: Track verifier context " Kumar Kartikeya Dwivedi
2026-07-13 15:38 ` [PATCH bpf-next v3 08/17] bpf: Report Register Type Safety errors Kumar Kartikeya Dwivedi
2026-07-13 15:38 ` [PATCH bpf-next v3 09/17] bpf: Report Memory Safety bounds errors Kumar Kartikeya Dwivedi
2026-07-13 15:38 ` [PATCH bpf-next v3 10/17] bpf: Report Resource Lifetime reference leaks Kumar Kartikeya Dwivedi
2026-07-13 16:04 ` sashiko-bot
2026-07-13 15:39 ` [PATCH bpf-next v3 11/17] bpf: Report Call Type Safety argument errors Kumar Kartikeya Dwivedi
2026-07-13 15:51 ` sashiko-bot
2026-07-13 15:39 ` [PATCH bpf-next v3 12/17] bpf: Report Execution Context Safety errors Kumar Kartikeya Dwivedi
2026-07-13 15:53 ` sashiko-bot
2026-07-13 15:39 ` [PATCH bpf-next v3 13/17] bpf: Report Program Structure CFG errors Kumar Kartikeya Dwivedi
2026-07-14 20:00 ` Eduard Zingerman
2026-07-15 7:37 ` Kumar Kartikeya Dwivedi [this message]
2026-07-13 15:39 ` [PATCH bpf-next v3 14/17] bpf: Report Policy helper and kfunc errors Kumar Kartikeya Dwivedi
2026-07-13 16:09 ` sashiko-bot
2026-07-13 15:39 ` [PATCH bpf-next v3 15/17] bpf: Report Verifier Limit errors Kumar Kartikeya Dwivedi
2026-07-13 15:39 ` [PATCH bpf-next v3 16/17] bpf: Report Verifier Internal errors Kumar Kartikeya Dwivedi
2026-07-14 23:17 ` Eduard Zingerman
2026-07-15 7:36 ` Kumar Kartikeya Dwivedi
2026-07-13 15:39 ` [PATCH bpf-next v3 17/17] bpf: Gate verifier diagnostics on log level Kumar Kartikeya Dwivedi
2026-07-14 3:36 ` kernel test robot
2026-07-14 6:10 ` [syzbot ci] Re: Redesign Verification Errors syzbot ci
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=DJYZ12G29BZ8.2JBXPFCGEQGJL@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=kkd@meta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox