* [PATCH] selftests/clone3: Check that the child exited cleanly
@ 2024-04-09 20:39 Mark Brown
2024-04-11 21:03 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2024-04-09 20:39 UTC (permalink / raw)
To: Christian Brauner, Shuah Khan; +Cc: linux-kernel, linux-kselftest, Mark Brown
When the child exits during the clone3() selftest we use WEXITSTATUS() to
get the exit status from the process without first checking WIFEXITED() to
see if the result will be valid. This can lead to incorrect results, for
example if the child exits due to signal. Add a WIFEXTED() check and report
any non-standard exit as a failure, using EXIT_FAILURE as the exit status
for call_clone3() since we otherwise report 0 or negative errnos.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
tools/testing/selftests/clone3/clone3.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
index 3c9bf0cd82a8..0e0e5dfa97c6 100644
--- a/tools/testing/selftests/clone3/clone3.c
+++ b/tools/testing/selftests/clone3/clone3.c
@@ -98,6 +98,11 @@ static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode)
ksft_print_msg("Child returned %s\n", strerror(errno));
return -errno;
}
+ if (!WIFEXITED(status)) {
+ ksft_print_msg("Child did not exit normally, status 0x%x\n",
+ status);
+ return EXIT_FAILURE;
+ }
if (WEXITSTATUS(status))
return WEXITSTATUS(status);
---
base-commit: 39cd87c4eb2b893354f3b850f916353f2658ae6f
change-id: 20240405-kselftest-clone3-signal-1edb1a3f5473
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests/clone3: Check that the child exited cleanly
2024-04-09 20:39 [PATCH] selftests/clone3: Check that the child exited cleanly Mark Brown
@ 2024-04-11 21:03 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2024-04-11 21:03 UTC (permalink / raw)
To: Mark Brown, Christian Brauner, Shuah Khan
Cc: linux-kernel, linux-kselftest, Shuah Khan
On 4/9/24 14:39, Mark Brown wrote:
> When the child exits during the clone3() selftest we use WEXITSTATUS() to
> get the exit status from the process without first checking WIFEXITED() to
> see if the result will be valid. This can lead to incorrect results, for
> example if the child exits due to signal. Add a WIFEXTED() check and report
> any non-standard exit as a failure, using EXIT_FAILURE as the exit status
> for call_clone3() since we otherwise report 0 or negative errnos.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> tools/testing/selftests/clone3/clone3.c | 5 +++++
> 1 file changed, 5 insertions(+)
Applied to linux-kselftest next for Linux 6.10-rc1.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-11 21:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 20:39 [PATCH] selftests/clone3: Check that the child exited cleanly Mark Brown
2024-04-11 21:03 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®