From: sashiko-bot@kernel.org
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 47/49] selftests/bpf: Test passes, instances, precision and the failing path
Date: Fri, 20 Nov 2026 08:30:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-224738@kernel.org> (raw)
In-Reply-To: <20261120074430.2704488-48-alexei.starovoitov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests/bpf: premature #endif around loads_6th() in
verifier_passes.c
--
commit ef0b2c0eaafb6e699dfff5dd0c5556a322cf2fa1
Author: Alexei Starovoitov <ast@kernel.org>
selftests/bpf: Test passes, instances, precision and the failing path
This commit adds BPF verifier selftests covering verification passes,
partitions, loop peeling, call instances, precision tracking, and
failing-path diagnostics.
> diff --git a/tools/testing/selftests/bpf/progs/verifier_passes.c b/tools/testing/selftests/bpf/progs/verifier_passes.c
> new file mode 100644
> index 0000000000000..a6edb33d0014b
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/verifier_passes.c
> @@ -0,0 +1,3636 @@
[ ... ]
> +/* clang ignores the arguments of a naked function */
> +#if defined(__clang__) || defined(__BPF_FEATURE_STACK_ARGUMENT)
> +static __naked __noinline __used long loads_6th(long a, long b, long c, long d, long e, long f)
> +{
> + /* r0 = *(u64 *)(r11 + 8) */
> + asm volatile (".8byte 0x8b079; exit;" ::: __clobber_all);
> +}
> +
> +SEC("tc")
> +__description("log: one report for a stack argument that is not there")
> +__failure __msg("callee expects 6 args")
> +__msg("Verification failed") __not_msg("Verification failed")
> +__load_if_JITed()
> +__arch_x86_64 __arch_arm64
> +__naked void log_of_missing_stack_arg(void)
> +{
> + asm volatile ("r1 = 1; r2 = 2; r3 = 3; r4 = 4; r5 = 5; call loads_6th; exit;"
> + ::: __clobber_all);
> +}
> +#endif
> +
> +/* *(u64 *)(r11 - 8) = imm */
> +#define STORE_6TH(imm) ".byte 0x7a; .byte 0xb; .short -8; .long " #imm ";"
> +#define ARGS_1_TO_5 "r1 = 1; r2 = 2; r3 = 3; r4 = 4; r5 = 5;"
> +
> +/* r7 is 0..15 with the argument, and add..add + 15 without it */
> +#define STORE_ON_ONE_PATH(add) \
> + "call %[bpf_get_prandom_u32];" \
> + "r7 = r0;" \
> + "r7 &= 15;" \
> + "call %[bpf_get_prandom_u32];" \
> + "if r0 == 0 goto 1f;" \
> + STORE_6TH(1) \
> + "goto 2f;" \
> +"1: r7 += " #add ";" \
> +"2: if r7 > 7 goto 9f;" \
> + ARGS_1_TO_5 \
> + "call loads_6th;" \
> + EXIT_AT_9
> +
> +SEC("tc")
> +__description("deps: only one state has the stack argument")
> +__success
> +__load_if_JITed()
> +__arch_x86_64 __arch_arm64
> +__naked void stack_arg_on_one_path(void)
> +{
> + ASM(STORE_ON_ONE_PATH(8));
> +}
> +
> +SEC("tc")
> +__description("deps: the state without the stack argument gets to the call")
> +__failure __msg("callee expects 6 args")
> +__load_if_JITed()
> +__arch_x86_64 __arch_arm64
> +__naked void stack_arg_on_one_path_bad(void)
> +{
> + ASM(STORE_ON_ONE_PATH(7));
> +}
> +
> +/* x * x - 21 * x + 110 is 0 for 10 and for 11 */
> +static __naked __noinline __used long roots_of_6th(long a, long b, long c, long d, long e, long f)
> +{
> + /* r6 = *(u64 *)(r11 + 8) */
> + ASM(".8byte 0x8b679;"
> + VALUE_IN_R9
> + "r1 = r6;"
> + "r1 *= r6;"
> + "r6 *= 21;"
> + "r1 -= r6;"
> + "r1 += 110;"
> + "r9 += r1;"
> + "r0 = *(u8 *)(r9 + 63);"
> + EXIT_AT_9);
> +}
> +
> +#define ROOTS_ON_STACK(second) \
> + "call %[bpf_get_prandom_u32];" \
> + STORE_6TH(10) \
> + "if r0 == 0 goto 1f;" \
> + STORE_6TH(second) \
> +"1:" ARGS_1_TO_5 \
> + "call roots_of_6th;" \
> + "exit;"
> +
> +SEC("tc")
> +__description("keep_disjoint_apart: a stack argument")
> +__success
> +__load_if_JITed()
> +__arch_x86_64 __arch_arm64
> +__naked void disjoint_stack_arg(void)
> +{
> + ASM(ROOTS_ON_STACK(11));
> +}
> +
> +SEC("tc")
> +__description("keep_disjoint_apart: a stack argument is no root")
> +__failure __msg("invalid access to map value, value_size=64 off=65 size=1")
> +__load_if_JITed()
> +__arch_x86_64 __arch_arm64
> +__naked void disjoint_stack_arg_bad(void)
> +{
> + ASM(ROOTS_ON_STACK(9));
> +}
[Severity: Medium]
Should the #endif after log_of_missing_stack_arg() be moved below
disjoint_stack_arg_bad()? When building with bpf-gcc without
__BPF_FEATURE_STACK_ARGUMENT, loads_6th() is not defined for
STORE_ON_ONE_PATH, and roots_of_6th() declares six parameters outside the
guard, breaking compilation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120074430.2704488-1-alexei.starovoitov@gmail.com?part=47
next prev parent reply other threads:[~2026-11-20 8:30 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:41 [PATCH bpf-next 00/49] bpf: Verify in passes, with equations in the state Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 01/49] bpf: Look for bpf_clone_redirect() once in check_recursion() Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 02/49] bpf: Make stack liveness faster Alexei Starovoitov
2026-11-20 8:01 ` sashiko-bot
2026-11-20 8:24 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 03/49] bpf: Delete the old main pass of the verifier Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 04/49] bpf: Delete scalar evolution Alexei Starovoitov
2026-11-20 8:03 ` sashiko-bot
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 05/49] bpf: Limit the cost and the memory of a load Alexei Starovoitov
2026-11-20 8:00 ` sashiko-bot
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 06/49] bpf: Record what each insn reads and writes Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 07/49] bpf: Name an id after the xreg that has it Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 08/49] bpf: Do not fail a check because a state has fewer values Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 8:39 ` sashiko-bot
2026-11-20 7:41 ` [PATCH bpf-next 09/49] bpf: Check fixups in the main pass and keep a snapshot of them Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 10/49] bpf: Reject a program with a call that needs two rewrites Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 11/49] bpf: Put a barrier where no mask fits Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 12/49] bpf: Keep more of what is known about a number Alexei Starovoitov
2026-11-20 8:18 ` sashiko-bot
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 13/49] bpf: Remember how many bytes of a packet are checked Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 14/49] bpf: Mark a state that no run of the program has Alexei Starovoitov
2026-11-20 8:24 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 15/49] bpf: Peel the first trips of a loop and join the other trips Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 16/49] bpf: Add equations and their arithmetic Alexei Starovoitov
2026-11-20 8:24 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 17/49] bpf: Keep a table of equations in each state Alexei Starovoitov
2026-11-20 8:17 ` sashiko-bot
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 18/49] bpf: Refine all related numbers after a jump Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 19/49] bpf: Make equations from ALU, spill, fill and call insns Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 8:26 ` sashiko-bot
2026-11-20 7:41 ` [PATCH bpf-next 20/49] bpf: Delete the equations that say nothing Alexei Starovoitov
2026-11-20 8:25 ` bot+bpf-ci
2026-11-20 7:41 ` [PATCH bpf-next 21/49] bpf: Compare states by join_key, then by value Alexei Starovoitov
2026-11-20 8:22 ` sashiko-bot
2026-11-20 7:41 ` [PATCH bpf-next 22/49] bpf: Continue a pass after an unproven insn Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 23/49] bpf: Find the xregs that an unproven insn depends on Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 24/49] bpf: Keep two states apart if data and control deps differ Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 25/49] bpf: Join any two states that have the same join_key Alexei Starovoitov
2026-11-20 8:25 ` sashiko-bot
2026-11-20 7:41 ` [PATCH bpf-next 26/49] bpf: Check the equations when a state is pruned or joined Alexei Starovoitov
2026-11-20 7:41 ` [PATCH bpf-next 27/49] bpf: Guess the equations of a join Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 28/49] bpf: Prune or join each state that arrives Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 29/49] bpf: Order the pending states and free the states that are done Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 30/49] bpf: Get the trip count from the trip index Alexei Starovoitov
2026-11-20 8:22 ` sashiko-bot
2026-11-20 7:42 ` [PATCH bpf-next 31/49] bpf: Give a loop a checked trip count or may_goto Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 32/49] bpf: Use the equations in the join rule Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 33/49] bpf: Verify a static function once for each instance Alexei Starovoitov
2026-11-20 8:33 ` sashiko-bot
2026-11-20 7:42 ` [PATCH bpf-next 34/49] bpf: Partition the states after an error Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 35/49] bpf: Reproduce an error on one path, with no joins Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 36/49] bpf: Do not let a join raise what a program requires Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 37/49] bpf: Verify in passes Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 38/49] bpf: Make a returned pointer to the stack unreadable Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 39/49] bpf: Keep two states apart if a live xreg has two types Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 40/49] bpf: Check the body of a counted loop once Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 41/49] bpf: Refine the copies of a number that AND or OR splits Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 42/49] bpf: Allow a range of offsets for a constant string Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 43/49] bpf: Keep spilled pointers at a range of stack offsets Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 44/49] selftests/bpf: Adjust tests to the new log text Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 45/49] selftests/bpf: Adjust tests that get another verdict or may_goto Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 46/49] selftests/bpf: Test barriers and far pointers Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 47/49] selftests/bpf: Test passes, instances, precision and the failing path Alexei Starovoitov
2026-11-20 8:30 ` sashiko-bot [this message]
2026-11-20 7:42 ` [PATCH bpf-next 48/49] selftests/bpf: Test equations Alexei Starovoitov
2026-11-20 7:42 ` [PATCH bpf-next 49/49] bpf, docs: Rewrite verifier.rst Alexei Starovoitov
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=sashiko-outbox-224738@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox