]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/bpf: make arg_parsing.c more robust to crashes
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 14 Oct 2025 20:20:37 +0000 (13:20 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 14 Oct 2025 23:39:33 +0000 (16:39 -0700)
commite603a342cf7ecd64ef8f36207dfe1caacb9e2583
tree7ef4da3dcb3154c388e9541e8602d2920fc8548b
parent7f9ee5fc97e14682e36fe22ae2654c07e4998b82
selftests/bpf: make arg_parsing.c more robust to crashes

We started getting a crash in BPF CI, which seems to originate from
test_parse_test_list_file() test and is happening at this line:

  ASSERT_OK(strcmp("test_with_spaces", set.tests[0].name), "test 0 name");

One way we can crash there is if set.cnt zero, which is checked for with
ASSERT_EQ() above, but we proceed after this regardless of the outcome.
Instead of crashing, we should bail out with test failure early.

Similarly, if parse_test_list_file() fails, we shouldn't be even looking
at set, so bail even earlier if ASSERT_OK() fails.

Fixes: 64276f01dce8 ("selftests/bpf: Test_progs can read test lists from file")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20251014202037.72922-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/arg_parsing.c