From: sashiko-bot@kernel.org
To: "Cheng-Yang Chou" <yphbchou0911@gmail.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH sched_ext/for-7.2] selftests/sched_ext: Fix select_cpu_dfl link leak on early return
Date: Fri, 08 May 2026 18:20:19 +0000 [thread overview]
Message-ID: <20260508182023.5D1CAC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508065514.1723906-1-yphbchou0911@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Child processes are leaked as zombies if an early return occurs during the `waitpid()` loop, bypassing the cleanup guarantee the patch aims to provide.
--
commit 804f29ba6f027f7b0b2d5d4230d76424d3576212
Author: Cheng-Yang Chou <yphbchou0911@gmail.com>
selftests/sched_ext: Fix select_cpu_dfl link leak on early return
This commit attempts to prevent a BPF link leak caused by early returns in
the run() function by moving the skeleton and link into a context struct
that is safely destroyed in cleanup().
> diff --git a/tools/testing/selftests/sched_ext/select_cpu_dfl.c b/tools/testing/selftests/sched_ext/select_cpu_dfl.c
> index 5b6e045e1109b..7e342c0cec653 100644
> --- a/tools/testing/selftests/sched_ext/select_cpu_dfl.c
> +++ b/tools/testing/selftests/sched_ext/select_cpu_dfl.c
[ ... ]
> @@ -43,25 +59,31 @@ static enum scx_test_status run(void *ctx)
> sleep(1);
> exit(0);
> }
> + if (pids[i] > 0)
> + nforked++;
> }
>
> for (i = 0; i < NUM_CHILDREN; i++) {
> + if (pids[i] <= 0)
> + continue;
> SCX_EQ(waitpid(pids[i], &status, 0), pids[i]);
> SCX_EQ(status, 0);
Does this leave child processes as zombies if an early return occurs
during the wait loop?
If SCX_EQ() triggers an immediate return before the loop finishes, any
remaining successfully forked child processes will be abandoned. Since the
pids array remains stack-allocated in run() and is not part of the context
struct, cleanup() has no way to find and wait on them.
Should the child pid tracking also be moved into the context struct
so that cleanup() can reap or kill any remaining children?
> }
>
> - SCX_ASSERT(!skel->bss->saw_local);
> -
> - bpf_link__destroy(link);
> + SCX_GT(nforked, 0);
> + SCX_ASSERT(!tctx->skel->bss->saw_local);
>
> return SCX_TEST_PASS;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508065514.1723906-1-yphbchou0911@gmail.com?part=1
prev parent reply other threads:[~2026-05-08 18:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 6:55 [PATCH sched_ext/for-7.2] selftests/sched_ext: Fix select_cpu_dfl link leak on early return Cheng-Yang Chou
2026-05-08 8:08 ` Andrea Righi
2026-05-08 9:54 ` Cheng-Yang Chou
2026-05-08 15:45 ` Tejun Heo
2026-05-08 18:20 ` 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=20260508182023.5D1CAC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
--cc=yphbchou0911@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