From: sashiko-bot@kernel.org
To: "Justin Suess" <utilityemal77@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Add test for map-stored struct file kptrs
Date: Tue, 21 Apr 2026 01:31:30 +0000 [thread overview]
Message-ID: <20260421013131.80787C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260420203306.3107246-3-utilityemal77@gmail.com>
Sashiko AI review found 2 potential issue(s):
- [High] Wrapping `RUN_TESTS()` inside `test__start_subtest()` breaks subtest filtering and creates dummy subtests.
- [Low] Zombie process leak if an error occurs before `waitpid()`.
--
commit a0fbd925d86bff9e8b40a48dc8cff998dbbb50fc
Author: Justin Suess <utilityemal77@gmail.com>
selftests/bpf: Add test for map-stored struct file kptrs
This commit adds tests for map-stored referenced struct file pointers. It
verifies that the file reference remains valid after the original file
descriptor is closed, and checks that unreferenced struct file pointers are
rejected by the verifier.
> diff --git a/tools/testing/selftests/bpf/prog_tests/refcounted_kptr_file.c b/tools/testing/selftests/bpf/prog_tests/refcounted_kptr_file.c
> new file mode 100644
> index 0000000000000..173121377040c
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/refcounted_kptr_file.c
[ ... ]
> + skel->bss->file_kptr_insert_pid = child_pid;
> + err = write_full(pipefd[1], "1", 1);
> + if (!ASSERT_OK(err, "start_child"))
> + goto out;
If an error occurs here and the code jumps to the out label, does it leave
the child process as a zombie?
It looks like the cleanup path closes the pipe file descriptors which causes
the child to read EOF and exit, but waitpid() isn't called in the cleanup
path.
[ ... ]
> +void test_refcounted_kptr_file(void)
> +{
> + if (test__start_subtest("holds_ref_after_close"))
> + run_refcounted_file_kptr_success();
> +
> + if (test__start_subtest("reject_unref_ctx_file"))
> + RUN_TESTS(refcounted_kptr_file_fail);
> +}
Can wrapping RUN_TESTS() inside test__start_subtest() break test filtering?
RUN_TESTS() internally parses the skeleton and creates its own subtests for
each BPF program by calling test__start_subtest_with_desc().
Since the selftests framework doesn't support nested subtests, if a user
filters for the inner program name (like -t refcounted_kptr_file/stash_unref_ctx_file),
the outer test__start_subtest() will not match the filter and will skip
RUN_TESTS() completely.
Should RUN_TESTS() be called unconditionally at the top level of the test
function instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260420203306.3107246-1-utilityemal77@gmail.com?part=2
prev parent reply other threads:[~2026-04-21 1:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 20:33 [PATCH bpf-next 0/2] Allow storing referenced struct file kptrs in BPF maps Justin Suess
2026-04-20 20:33 ` [PATCH bpf-next 1/2] bpf: Implement dtor for struct file BTF ID Justin Suess
2026-04-20 22:17 ` Song Liu
2026-04-21 1:05 ` sashiko-bot
2026-04-21 2:18 ` Justin Suess
2026-04-21 19:38 ` Justin Suess
2026-04-21 20:29 ` Kumar Kartikeya Dwivedi
2026-04-20 20:33 ` [PATCH bpf-next 2/2] selftests/bpf: Add test for map-stored struct file kptrs Justin Suess
2026-04-20 21:07 ` bot+bpf-ci
2026-04-20 22:28 ` Song Liu
2026-04-21 1:31 ` sashiko-bot [this message]
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=20260421013131.80787C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=utilityemal77@gmail.com \
/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