summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/clone3
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2024-04-09 23:39:43 +0300
committerShuah Khan <skhan@linuxfoundation.org>2024-05-06 22:57:20 +0300
commit698eb790e016427bf3b2e55693e653222af13691 (patch)
tree07c83ea4ac8ad8956a2dcbed9874d3db25e3b762 /tools/testing/selftests/clone3
parent7b8674cae80f68304ec6628e455c169a7dc2ad0d (diff)
downloadlinux-698eb790e016427bf3b2e55693e653222af13691.tar.xz
selftests/clone3: Check that the child exited cleanly
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> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/clone3')
-rw-r--r--tools/testing/selftests/clone3/clone3.c5
1 files changed, 5 insertions, 0 deletions
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);