Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <usama.anjum@collabora.com>
Link: https://lore.kernel.org/r/20240313185606.work.073-kees@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>

+7 -5
+7 -5
tools/testing/selftests/exec/execveat.c
··· 98 98 if (child == 0) { 99 99 /* Child: do execveat(). */ 100 100 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", 102 102 rc, errno, strerror(errno)); 103 - ksft_test_result_fail("%s\n", test_name); 104 - exit(1); /* should not reach here */ 103 + exit(errno); 105 104 } 106 105 /* Parent: wait for & check child's exit status. */ 107 106 rc = waitpid(child, &status, 0); ··· 225 226 * "If the command name is found, but it is not an executable utility, 226 227 * the exit status shall be 126."), so allow either. 227 228 */ 228 - if (is_script) 229 + if (is_script) { 230 + ksft_print_msg("Invoke script via root_dfd and relative filename\n"); 229 231 fail += check_execveat_invoked_rc(root_dfd, longpath + 1, 0, 230 232 127, 126); 231 - else 233 + } else { 234 + ksft_print_msg("Invoke exec via root_dfd and relative filename\n"); 232 235 fail += check_execveat(root_dfd, longpath + 1, 0); 236 + } 233 237 234 238 return fail; 235 239 }