From: sashiko-bot@kernel.org
To: "Alex Williamson" <alex.williamson@nvidia.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] selftests/harness: Drain the test process group after a timeout
Date: Thu, 10 Sep 2026 23:13:34 +0000 [thread overview]
Message-ID: <20260910231335.7B5E71F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910230254.1198094-1-alex.williamson@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Pre-existing process group initialization race leaves child process running concurrently on timeout.
- [High] Test child process and its process group are leaked if pidfd_open() or poll() fail.
--
commit 2f6bf81e41b5489d0a1cc6b990abec031b22d521
Author: Alex Williamson <alex.williamson@nvidia.com>
selftests/harness: Drain the test process group after a timeout
This commit updates the kselftest harness to actively wait for the entire
process group to exit when a test times out, bounded by a 5 second limit.
This addresses cascading failures caused by grandchild processes outliving
the timeout and holding onto exclusive resources.
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index 29a19bc870846..4e479c8cb49e8 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -981,8 +982,7 @@ static void __wait_for_test(struct __test_metadata *t)
> */
> int status = KSFT_FAIL << 8;
> struct pollfd poll_child;
> - int ret, child, childfd;
> - bool timed_out = false;
> + int ret, child = 0, childfd;
>
> childfd = syscall(__NR_pidfd_open, t->pid, 0);
> if (childfd == -1) {
[Severity: High]
This is a pre-existing issue, but if syscall(__NR_pidfd_open) fails, the
function returns immediately. Can this leak the running child process and
its process group? If the leaked child holds exclusive resources like vfio
devices, could it cause subsequent tests to fail?
[ ... ]
> @@ -1004,9 +1004,46 @@ static void __wait_for_test(struct __test_metadata *t)
> t->name);
> return;
[Severity: High]
This is a pre-existing issue, but similarly, if poll() fails (e.g. returning
-1 with errno == EINTR), the function logs an error and returns. Doesn't
this also leak the child process and its process group by completely bypassing
the SIGKILL and waitpid() cleanup logic?
> } else if (ret == 0) {
> - timed_out = true;
> + int elapsed_ms = 0;
> +
> /* signal process group */
> kill(-(t->pid), SIGKILL);
[Severity: High]
This is a pre-existing issue, but is there a race condition here between the
parent calling kill() and the child calling setpgrp()?
If the child process created in __run_test() is delayed and hasn't executed
setpgrp() yet when this timeout occurs:
__run_test()
child = fork();
...
} else if (child == 0) {
setpgrp();
Would this kill(-(t->pid), SIGKILL) fail with ESRCH because the process
group doesn't exist yet? This could result in the signal being lost, leaving
the child alive to run concurrently with subsequent tests once it is
scheduled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260910230254.1198094-1-alex.williamson@nvidia.com?part=1
prev parent reply other threads:[~2026-09-10 23:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 23:02 [PATCH] selftests/harness: Drain the test process group after a timeout Alex Williamson
2026-09-10 23:13 ` 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=20260910231335.7B5E71F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alex.williamson@nvidia.com \
--cc=kvm@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).