All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 04/17] bpf: Prune verifier diagnostics when switching paths
Date: Mon, 13 Jul 2026 16:02:32 +0000	[thread overview]
Message-ID: <20260713160232.C90741F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713153910.2556007-5-memxor@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unconditional truncation of the diagnostic event log in `pop_stack()` destroys the diagnostic trace when the verifier encounters an error.
- [Low] The commit message inaccurately claims to add logic to record the active branch, but this logic was already introduced in a preceding patch.
--

--- Patch [4]: [PATCH bpf-next v3 04/17] bpf: Prune verifier diagnostics when switching paths ---
commit 59e4455992c872528b5e207bc7864d38d2ea193e
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>

bpf: Prune verifier diagnostics when switching paths
    
This commit saves the diagnostic event-log position with each verifier stack
entry and resets it when a queued state is popped or after a successful
subprogram verification. It also queues diagnostic outcomes for branches and
appends them when states are popped.

> Record branch outcomes as true or false. Later reports use those events to
> show the path that reached a verifier error. For queued branches, save the
> queued outcome with the verifier stack entry and append it when that state is
> popped; record the active branch immediately before continuing.

[Severity: Low]
This isn't a bug, but the commit message states it adds logic to "record the
active branch immediately before continuing". However, looking at the code, it
appears this logic was already introduced in a preceding patch and is not
actually part of this commit's diff in check_cond_jmp_op(). Should the commit
message be updated to reflect only the changes made here?

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c

[ ... ]

> @@ -1706,8 +1710,8 @@ void bpf_free_backedges(struct bpf_scc_visit *visit)
>  	visit->backedges = NULL;
>  }
>  
> -static int pop_stack(struct bpf_verifier_env *env, int *prev_insn_idx,
> -		     int *insn_idx, bool pop_log)
> +static int pop_stack(struct bpf_verifier_env *env, int *prev_insn_idx, int *insn_idx, bool pop_log,
> +		     bool activate_diag_branch)
>  {
>  	struct bpf_verifier_state *cur = env->cur_state;
>  	struct bpf_verifier_stack_elem *elem, *head = env->head;
> @@ -1723,6 +1727,12 @@ static int pop_stack(struct bpf_verifier_env *env, int *prev_insn_idx,
>  	}
>  	if (pop_log)
>  		bpf_vlog_reset(&env->log, head->log_pos);
> +	bpf_diag_event_log_reset(env, head->diag_log_pos);

[Severity: High]
When a program fails verification, do_check() returns a negative error, causing
do_check_common() to call free_states(). 

free_states() loops over the remaining states, calling pop_stack() with false 
for both pop_log and activate_diag_branch:

kernel/bpf/verifier.c:free_states() {
    ...
    while (!pop_stack(env, NULL, NULL, false, false))
        ;
    ...
}

Because bpf_diag_event_log_reset() is called unconditionally here in pop_stack(),
won't this truncate or completely destroy the diagnostic trace during error
cleanup?

If the log is rolled back to the length it had when each unvisited state was 
queued, does this result in an empty or useless diagnostic output for users 
trying to debug verifier failures? Should this reset also be conditional?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260713153910.2556007-1-memxor@gmail.com?part=4

  reply	other threads:[~2026-07-13 16:02 UTC|newest]

Thread overview: 28+ 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 [this message]
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-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-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=20260713160232.C90741F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=sashiko-reviews@lists.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.