BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: One basic block and the way to it in the level 1 log
@ 2026-11-08  5:39 Alexei Starovoitov
  2026-11-08  5:39 ` [PATCH bpf-next 1/2] bpf: Take the end of the verifier log out and append it later Alexei Starovoitov
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alexei Starovoitov @ 2026-11-08  5:39 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, eddyz87, memxor

From: Alexei Starovoitov <ast@kernel.org>

At log level 1 the verifier prints each insn when it verifies it. It used
to follow one path at a time. push_stack() noted the end of the log when
it put a branch aside, and pop_stack() moved the log back there when it
took the branch. So the log was the path from the first insn to the
current one: never larger than the longest path, and for a rejected prog
the path to the error.

Since commit 2d0b457611c0 ("Merge branch
'bpf-a-verifier-that-joins-states'") there are no paths. Basic blocks are
verified in the order of the control flow graph, and the states that get
to a block are joined. pop_stack() is gone, push_stack() notes nothing,
and nothing else moves the log back while a function is verified. The log
holds every block that was verified, each time it was verified.

Two things broke:

- The log of a large prog is many times larger, 15 to 35 times for the
  three below. The text is dropped when the prog is safe, but the buffer
  has to hold the log at its largest. Valid progs of Cilium, katran and
  scx that are loaded the way bpf(2) shows it, with log_level 1 and
  a static buffer, get -ENOSPC with 64K.
- The log of a rejected prog is not the path to the error. It has all
  blocks, both arms of each branch, in the order in which they were
  verified.

1  Two helpers for the log: take its end out, append it later.
2  The level 1 log holds one basic block at a time. When a block is
   rejected the way to it is printed in front of it, from the edges that
   the states at joins came by. Nothing is verified twice. A prog that
   loads pays two stores per state.

log_true_size at level 1           one path   all blocks   this series
  bpf_lxc/tail_ipv4_ct_egress         51434       774446         7652
  bpf_host/cil_to_netdev             101212      1789015         9778
  katran/balancer_ingress            103567      3668559        22603
  progs with -ENOSPC at 64K            2841         5503           45
  the builds of a prog as one           435         1018           23

Level 2 is not changed.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Alexei Starovoitov (2):
  bpf: Take the end of the verifier log out and append it later
  bpf: Keep one basic block in the level 1 log and print the way to it

 include/linux/bpf_verifier.h                       |  10 ++
 kernel/bpf/flow.c                                  | 111 ++++++++++++++++++--
 kernel/bpf/log.c                                   |  47 +++++++++
 kernel/bpf/verifier.c                              |  20 +++-
 .../testing/selftests/bpf/progs/linked_list_peek.c |   2 +-
 tools/testing/selftests/bpf/progs/rbtree_search.c  |   4 +-
 .../testing/selftests/bpf/progs/verifier_bounds.c  |   2 +-
 7 files changed, 181 insertions(+), 15 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-08 16:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-08  5:39 [PATCH bpf-next 0/2] bpf: One basic block and the way to it in the level 1 log Alexei Starovoitov
2026-11-08  5:39 ` [PATCH bpf-next 1/2] bpf: Take the end of the verifier log out and append it later Alexei Starovoitov
2026-11-08  6:03   ` sashiko-bot
2026-11-08 16:08     ` Alexei Starovoitov
2026-11-08  5:39 ` [PATCH bpf-next 2/2] bpf: Keep one basic block in the level 1 log and print the way to it Alexei Starovoitov
2026-11-08  6:02   ` sashiko-bot
2026-11-08 16:08     ` Alexei Starovoitov
2026-11-08 16:20 ` [PATCH bpf-next 0/2] bpf: One basic block and the way to it in the level 1 log patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox