Skip to content

Commit 0ef58cc

Browse files
committed
selftests/exec: execveat: Improve debug reporting
Children processes were reporting their status, duplicating the parent's. Remove that, and add some additional details about the test execution. Reviewed-by: Muhammad Usama Anjum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 1d0e51b commit 0ef58cc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tools/testing/selftests/exec/execveat.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ static int check_execveat_invoked_rc(int fd, const char *path, int flags,
9898
if (child == 0) {
9999
/* Child: do execveat(). */
100100
rc = execveat_(fd, path, argv, envp, flags);
101-
ksft_print_msg("execveat() failed, rc=%d errno=%d (%s)\n",
101+
ksft_print_msg("child execveat() failed, rc=%d errno=%d (%s)\n",
102102
rc, errno, strerror(errno));
103-
ksft_test_result_fail("%s\n", test_name);
104-
exit(1); /* should not reach here */
103+
exit(errno);
105104
}
106105
/* Parent: wait for & check child's exit status. */
107106
rc = waitpid(child, &status, 0);
@@ -226,11 +225,14 @@ static int check_execveat_pathmax(int root_dfd, const char *src, int is_script)
226225
* "If the command name is found, but it is not an executable utility,
227226
* the exit status shall be 126."), so allow either.
228227
*/
229-
if (is_script)
228+
if (is_script) {
229+
ksft_print_msg("Invoke script via root_dfd and relative filename\n");
230230
fail += check_execveat_invoked_rc(root_dfd, longpath + 1, 0,
231231
127, 126);
232-
else
232+
} else {
233+
ksft_print_msg("Invoke exec via root_dfd and relative filename\n");
233234
fail += check_execveat(root_dfd, longpath + 1, 0);
235+
}
234236

235237
return fail;
236238
}

0 commit comments

Comments
 (0)