* [PATCH bpf-next 1/2] selftests/bpf: test_verifier verbose causes erroneous failures
2025-05-12 14:04 [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode Gregory Bell
@ 2025-05-12 14:04 ` Gregory Bell
2025-05-12 14:04 ` [PATCH bpf-next 2/2] selftests/bpf: test_verifier verbose log overflows Gregory Bell
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Gregory Bell @ 2025-05-12 14:04 UTC (permalink / raw)
To: bpf
Cc: andrii, eddyz87, mykolal, ast, daniel, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah,
Gregory Bell
When running test_verifier with the -v flag and a test with
`expected_ret==VERBOSE_ACCEPT`, the opts.log_level is unintentionally
overwritten because the verbose flag takes precedence. This leads to
a mismatch in the expected and actual contents of bpf_vlog, causing
tests to fail incorrectly.
Reorder the conditional logic that sets opts.log_level to preserve
the expected log level and prevent it from being overridden by -v.
Signed-off-by: Gregory Bell <grbell@redhat.com>
---
tools/testing/selftests/bpf/test_verifier.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 447b68509d76..2d13e862b078 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -1559,10 +1559,10 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
test->errstr_unpriv : test->errstr;
opts.expected_attach_type = test->expected_attach_type;
- if (verbose)
- opts.log_level = verif_log_level | 4; /* force stats */
- else if (expected_ret == VERBOSE_ACCEPT)
+ if (expected_ret == VERBOSE_ACCEPT)
opts.log_level = 2;
+ else if (verbose)
+ opts.log_level = verif_log_level | 4; /* force stats */
else
opts.log_level = DEFAULT_LIBBPF_LOG_LEVEL;
opts.prog_flags = pflags;
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH bpf-next 2/2] selftests/bpf: test_verifier verbose log overflows
2025-05-12 14:04 [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode Gregory Bell
2025-05-12 14:04 ` [PATCH bpf-next 1/2] selftests/bpf: test_verifier verbose causes erroneous failures Gregory Bell
@ 2025-05-12 14:04 ` Gregory Bell
2025-05-12 17:26 ` [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode Eduard Zingerman
2025-05-12 17:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Gregory Bell @ 2025-05-12 14:04 UTC (permalink / raw)
To: bpf
Cc: andrii, eddyz87, mykolal, ast, daniel, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah,
Gregory Bell
Tests:
- 458/p ld_dw: xor semi-random 64-bit imms, test 5
- 501/p scale: scale test 1
- 502/p scale: scale test 2
fail in verbose mode due to bpf_vlog[] overflowing. These tests
generate large verifier logs that exceed the current buffer size,
causing them to fail to load.
Increase the size of the bpf_vlog[] buffer to accommodate larger
logs and prevent false failures during test runs with verbose output.
Signed-off-by: Gregory Bell <grbell@redhat.com>
---
tools/testing/selftests/bpf/test_verifier.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 2d13e862b078..27db34ecf3f5 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -734,7 +734,7 @@ static __u32 btf_raw_types[] = {
BTF_MEMBER_ENC(71, 13, 128), /* struct prog_test_member __kptr *ptr; */
};
-static char bpf_vlog[UINT_MAX >> 8];
+static char bpf_vlog[UINT_MAX >> 5];
static int load_btf_spec(__u32 *types, int types_len,
const char *strings, int strings_len)
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode
2025-05-12 14:04 [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode Gregory Bell
2025-05-12 14:04 ` [PATCH bpf-next 1/2] selftests/bpf: test_verifier verbose causes erroneous failures Gregory Bell
2025-05-12 14:04 ` [PATCH bpf-next 2/2] selftests/bpf: test_verifier verbose log overflows Gregory Bell
@ 2025-05-12 17:26 ` Eduard Zingerman
2025-05-12 17:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Eduard Zingerman @ 2025-05-12 17:26 UTC (permalink / raw)
To: Gregory Bell
Cc: bpf, andrii, mykolal, ast, daniel, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah
Gregory Bell <grbell@redhat.com> writes:
> This patch series fixes two issues that cause false failures in the
> BPF verifier test suite when run with verbose output (`-v`).
>
> The following tests fail only when running the test_verifier in
> verbose.
>
> #458/p ld_dw: xor semi-random 64 bit imms, test 5 FAIL
> #494/p precise: test 1 FAIL
> #495/p precise: test 2 FAIL
> #497/p precise: ST zero to stack insn is supported FAIL
> #498/p precise: STX insn causing spi > allocated_stack FAIL
> #501/p scale: scale test 1 FAIL
> #502/p scale: scale test 2 FAIL
>
> This leads to inconsistent results across verbose and
> non-verbose runs.
>
> Patch 1 addresses an issue where the verbose flag (`-v`) unintentionally
> overrides the `opts.log_level`, leading to incorrect contents when checking
> bpf_vlog in tests with `expected_ret == VERBOSE_ACCEPT`. This occurs when
> running verbose with `-v` but not `-vv`
>
> Patch 2 increases the size of the `bpf_vlog[]` buffer to prevent truncation
> of large verifier logs, which was causing failures in several scale and
> 64-bit immediate tests.
>
>
> Before patches:
> ./test_verifier | grep FAIL
> Summary: 790 PASSED, 0 SKIPPED, 0 FAILED
Can reproduce the issue with -v option, the series fixes failures I see.
Tested-by: Eduard Zingerman <eddyz87@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode
2025-05-12 14:04 [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode Gregory Bell
` (2 preceding siblings ...)
2025-05-12 17:26 ` [PATCH bpf-next 0/2] Fix verifier test failures in verbose mode Eduard Zingerman
@ 2025-05-12 17:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-12 17:50 UTC (permalink / raw)
To: Gregory Bell
Cc: bpf, andrii, eddyz87, mykolal, ast, daniel, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah
Hello:
This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Mon, 12 May 2025 10:04:11 -0400 you wrote:
> This patch series fixes two issues that cause false failures in the
> BPF verifier test suite when run with verbose output (`-v`).
>
> The following tests fail only when running the test_verifier in
> verbose.
>
> #458/p ld_dw: xor semi-random 64 bit imms, test 5 FAIL
> #494/p precise: test 1 FAIL
> #495/p precise: test 2 FAIL
> #497/p precise: ST zero to stack insn is supported FAIL
> #498/p precise: STX insn causing spi > allocated_stack FAIL
> #501/p scale: scale test 1 FAIL
> #502/p scale: scale test 2 FAIL
>
> [...]
Here is the summary with links:
- [bpf-next,1/2] selftests/bpf: test_verifier verbose causes erroneous failures
https://git.kernel.org/bpf/bpf-next/c/c5bcc8c78127
- [bpf-next,2/2] selftests/bpf: test_verifier verbose log overflows
https://git.kernel.org/bpf/bpf-next/c/af8a5125a04c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread