All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qiliang Yuan" <odys.yuan@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 3/4] selftests/bpf: Test freeing a struct_ops map under a running prog
Date: Fri, 16 Oct 2026 03:11:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-173655@kernel.org> (raw)
In-Reply-To: <20261016-selftests-bpf-struct-ops-assoc-timer-v4-3-9ad31c21220c@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] selftests/bpf: Missing error path abort leads to test timeout or cascading failures
--

commit 920a79a19e26a9e6930a47b303037de287f29b6a
Author: Qiliang Yuan <odys.yuan@gmail.com>

selftests/bpf: Test freeing a struct_ops map under a running prog
    
This commit adds a new test to verify that a struct_ops map is not freed
under a running program. It refactors existing timer tests to use a shared
helper function.

> diff --git a/tools/testing/selftests/bpf/prog_tests/test_struct_ops_assoc.c b/tools/testing/selftests/bpf/prog_tests/test_struct_ops_assoc.c
> index 461ded7223515..9d56e8cb5675a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_struct_ops_assoc.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_struct_ops_assoc.c
> @@ -157,12 +158,18 @@ static void test_st_ops_assoc_in_timer_no_uref(void)
>  	/*
>  	 * Run .test_1 by calling kfunc bpf_kfunc_multi_st_ops_test_1_prog_arg() and checks
>  	 * the return value. .test_1 will also schedule timer_cb that runs .test_1 again.
[ ... ]
>  	err = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.syscall_prog), NULL);
> -	ASSERT_OK(err, "bpf_prog_test_run_opts");
> +	if (!ASSERT_OK(err, "bpf_prog_test_run_opts")) {
> +		bpf_link__destroy(link);
> +		goto out;
> +	}

[Severity: Low]
Adding an abort on failure here is a nice improvement, as it prevents an
infinite loop waiting for the timer callback.

However, there are a couple of other places missing an error abort. In this
same function (run_st_ops_assoc_in_timer_no_uref), if
bpf_program__assoc_struct_ops() fails:

    err = bpf_program__assoc_struct_ops(skel->progs.syscall_prog,
                                        skel->maps.st_ops_map, NULL);
    ASSERT_OK(err, "bpf_program__assoc_struct_ops");
    
    link = bpf_map__attach_struct_ops(skel->maps.st_ops_map);

Will this cascade into failures on the subsequent attach? Should we add an
abort there as well?

Additionally, in the unmodified test_st_ops_assoc_in_timer() function in
this same file, bpf_prog_test_run_opts() is still checked with just
ASSERT_OK() and does not abort. If it fails, won't the test hang
indefinitely in its sched_yield() loop waiting for the timer callback
since the callback never runs?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016-selftests-bpf-struct-ops-assoc-timer-v4-0-9ad31c21220c@gmail.com?part=3

  reply	other threads:[~2026-10-16  3:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  2:59 [PATCH bpf-next v4 0/4] bpf: Fix a struct_ops use-after-free behind a flaky assoc_in_timer test Qiliang Yuan
2026-10-16  2:59 ` [PATCH bpf-next v4 1/4] bpf: Protect the struct_ops association with a spinlock Qiliang Yuan
2026-10-16  2:59 ` [PATCH bpf-next v4 2/4] bpf: Dissociate struct_ops progs before the grace period of the map Qiliang Yuan
2026-10-16  2:59 ` [PATCH bpf-next v4 3/4] selftests/bpf: Test freeing a struct_ops map under a running prog Qiliang Yuan
2026-10-16  3:11   ` sashiko-bot [this message]
2026-10-16  2:59 ` [PATCH bpf-next v4 4/4] selftests/bpf: Wait for the struct_ops map to be freed in assoc_in_timer Qiliang Yuan

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-173655@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=odys.yuan@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.