From: Donet Tom <donettom@linux.ibm.com>
To: Hu Song <husong@kylinos.cn>,
akpm@linux-foundation.org, david@kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org
Cc: ljs@kernel.org, liam@infradead.org, vbabka@kernel.org,
rppt@kernel.org, surenb@google.com, mhocko@suse.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm: handle fork() failure in migration tests
Date: Mon, 11 May 2026 15:52:41 +0530 [thread overview]
Message-ID: <3d66e75c-4039-40a8-a8d9-e8db62c13b16@linux.ibm.com> (raw)
In-Reply-To: <20260511093433.2372985-1-husong@kylinos.cn>
Hi
On 5/11/26 3:04 PM, Hu Song wrote:
> From: Song Hu <husong@kylinos.cn>
>
> When fork() fails and returns -1, the code falls into the else branch
> and stores -1 into self->pids[i]. Later, kill(-1, SIGTERM) is called
> which sends SIGTERM to every process the user has permission to signal,
> potentially killing the entire user session.
>
> Add an explicit check for fork() returning -1 (pid < 0). On failure,
> clean up any already-forked children before failing the test via
> ASSERT_GE(pid, 0). This fix is applied to all three fork() call sites
> in shared_anon, shared_anon_thp, and shared_anon_htlb tests.
>
> Signed-off-by: Hu Song <husong@kylinos.cn>
I am seeing the below issue in checkpatch.pl.
WARNING: From:/Signed-off-by: email name mismatch: 'From: Song Hu
<husong@kylinos.cn>' != 'Signed-off-by: Hu Song <husong@kylinos.cn>'
-Donet
> ---
> tools/testing/selftests/mm/migration.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c
> index 60e78bbfc0e3..f433e4f195ad 100644
> --- a/tools/testing/selftests/mm/migration.c
> +++ b/tools/testing/selftests/mm/migration.c
> @@ -163,6 +163,11 @@ TEST_F_TIMEOUT(migration, shared_anon, 2*RUNTIME)
> memset(ptr, 0xde, TWOMEG);
> for (i = 0; i < self->nthreads - 1; i++) {
> pid = fork();
> + if (pid < 0) {
> + while (--i >= 0)
> + kill(self->pids[i], SIGTERM);
> + ASSERT_GE(pid, 0);
> + }
> if (!pid) {
> prctl(PR_SET_PDEATHSIG, SIGHUP);
> /* Parent may have died before prctl so check now. */
> @@ -235,6 +240,11 @@ TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME)
> memset(ptr, 0xde, TWOMEG);
> for (i = 0; i < self->nthreads - 1; i++) {
> pid = fork();
> + if (pid < 0) {
> + while (--i >= 0)
> + kill(self->pids[i], SIGTERM);
> + ASSERT_GE(pid, 0);
> + }
> if (!pid) {
> prctl(PR_SET_PDEATHSIG, SIGHUP);
> /* Parent may have died before prctl so check now. */
> @@ -295,6 +305,11 @@ TEST_F_TIMEOUT(migration, shared_anon_htlb, 2*RUNTIME)
> memset(ptr, 0xde, TWOMEG);
> for (i = 0; i < self->nthreads - 1; i++) {
> pid = fork();
> + if (pid < 0) {
> + while (--i >= 0)
> + kill(self->pids[i], SIGTERM);
> + ASSERT_GE(pid, 0);
> + }
> if (!pid) {
> prctl(PR_SET_PDEATHSIG, SIGHUP);
> /* Parent may have died before prctl so check now. */
next prev parent reply other threads:[~2026-05-11 10:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 9:34 [PATCH] selftests/mm: handle fork() failure in migration tests Hu Song
2026-05-11 10:22 ` Donet Tom [this message]
2026-05-11 12:47 ` David Hildenbrand (Arm)
2026-05-11 16:44 ` Mike Rapoport
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=3d66e75c-4039-40a8-a8d9-e8db62c13b16@linux.ibm.com \
--to=donettom@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=husong@kylinos.cn \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@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 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.