Skip to content

Commit 698eb79

Browse files
broonieshuahkh
authored andcommitted
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 <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 7b8674c commit 698eb79

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/testing/selftests/clone3/clone3.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode)
9898
ksft_print_msg("Child returned %s\n", strerror(errno));
9999
return -errno;
100100
}
101+
if (!WIFEXITED(status)) {
102+
ksft_print_msg("Child did not exit normally, status 0x%x\n",
103+
status);
104+
return EXIT_FAILURE;
105+
}
101106
if (WEXITSTATUS(status))
102107
return WEXITSTATUS(status);
103108

0 commit comments

Comments
 (0)