BPF List
 help / color / mirror / Atom feed
From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	martin.lau@kernel.org
Cc: kernel-team@meta.com
Subject: Re: [PATCH bpf-next] selftests/bpf: make arg_parsing.c more robust to crashes
Date: Tue, 14 Oct 2025 16:01:44 -0700	[thread overview]
Message-ID: <2053ee20-716a-4e5f-b3a7-b1a08b6c9a1a@linux.dev> (raw)
In-Reply-To: <20251014202037.72922-1-andrii@kernel.org>

On 10/14/25 1:20 PM, Andrii Nakryiko wrote:
> 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>

This patch in combination with another arg_parsing.c fix [1] mitigates
recent BPF CI failures:
https://github.com/kernel-patches/vmtest/actions/runs/18510075579?pr=404

Tested-by: Ihor Solodrai <ihor.solodrai@linux.dev>

[1] https://lore.kernel.org/bpf/20251014080323.1660391-1-higuoxing@gmail.com/


> ---
>  tools/testing/selftests/bpf/prog_tests/arg_parsing.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
> index bb143de68875..fbf0d9c2f58b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
> +++ b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
> @@ -146,9 +146,12 @@ static void test_parse_test_list_file(void)
>  
>  	init_test_filter_set(&set);
>  
> -	ASSERT_OK(parse_test_list_file(tmpfile, &set, true), "parse file");
> +	if (!ASSERT_OK(parse_test_list_file(tmpfile, &set, true), "parse file"))
> +		goto out_fclose;
> +
> +	if (!ASSERT_EQ(set.cnt, 4, "test  count"))
> +		goto out_free_set;
>  
> -	ASSERT_EQ(set.cnt, 4, "test  count");
>  	ASSERT_OK(strcmp("test_with_spaces", set.tests[0].name), "test 0 name");
>  	ASSERT_EQ(set.tests[0].subtest_cnt, 0, "test 0 subtest count");
>  	ASSERT_OK(strcmp("testA", set.tests[1].name), "test 1 name");
> @@ -158,8 +161,8 @@ static void test_parse_test_list_file(void)
>  	ASSERT_OK(strcmp("testB", set.tests[2].name), "test 2 name");
>  	ASSERT_OK(strcmp("testC_no_eof_newline", set.tests[3].name), "test 3 name");
>  
> +out_free_set:
>  	free_test_filter_set(&set);
> -
>  out_fclose:
>  	fclose(fp);
>  out_remove:


  reply	other threads:[~2025-10-14 23:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 20:20 [PATCH bpf-next] selftests/bpf: make arg_parsing.c more robust to crashes Andrii Nakryiko
2025-10-14 23:01 ` Ihor Solodrai [this message]
2025-10-15  0:00 ` patchwork-bot+netdevbpf

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=2053ee20-716a-4e5f-b3a7-b1a08b6c9a1a@linux.dev \
    --to=ihor.solodrai@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    /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