Skip to contentSkip to conversation

selftests/exec: execveat: Improve debug reporting

PATCH In review Kees Cook 3 participants 5 messages Mar 13, 2024 – Mar 27, 2024

Subsystems (3)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 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.

---
Cc: Eric Biederman <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Muhammad Usama Anjum <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 tools/testing/selftests/exec/execveat.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tools/testing/selftests/exec/execveat.c +7 -5
index 0546ca24f2b2..6418ded40bdd 100644
@@ -98,10 +98,9 @@ static int check_execveat_invoked_rc(int fd, const char *path, int flags,
 	if (child == 0) {
 		/* Child: do execveat(). */
 		rc = execveat_(fd, path, argv, envp, flags);
-		ksft_print_msg("execveat() failed, rc=%d errno=%d (%s)\n",
+		ksft_print_msg("child execveat() failed, rc=%d errno=%d (%s)\n",
 			       rc, errno, strerror(errno));
-		ksft_test_result_fail("%s\n", test_name);
-		exit(1);  /* should not reach here */
+		exit(errno);
 	}
 	/* Parent: wait for & check child's exit status. */
 	rc = waitpid(child, &status, 0);
@@ -226,11 +225,14 @@ static int check_execveat_pathmax(int root_dfd, const char *src, int is_script)
 	 * "If the command name is found, but it is not an executable utility,
 	 * the exit status shall be 126."), so allow either.
 	 */
-	if (is_script)
+	if (is_script) {
+		ksft_print_msg("Invoke script via root_dfd and relative filename\n");
 		fail += check_execveat_invoked_rc(root_dfd, longpath + 1, 0,
 						  127, 126);
-	else
+	} else {
+		ksft_print_msg("Invoke exec via root_dfd and relative filename\n");
 		fail += check_execveat(root_dfd, longpath + 1, 0);
+	}
 
 	return fail;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Kees Cook

Children processes were reporting their status, duplicating the parent's. Remove that, and add some additional details about the test execution.

Quoted 8 lines

---
Cc: Eric Biederman <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Muhammad Usama Anjum <[email protected]>
Cc: [email protected]
Cc: [email protected]

Quoted 38 lines
---
 tools/testing/selftests/exec/execveat.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tools/testing/selftests/exec/execveat.c +7 -5
index 0546ca24f2b2..6418ded40bdd 100644
@@ -98,10 +98,9 @@ static int check_execveat_invoked_rc(int fd, const char *path, int flags,
 	if (child == 0) {
 		/* Child: do execveat(). */
 		rc = execveat_(fd, path, argv, envp, flags);
-		ksft_print_msg("execveat() failed, rc=%d errno=%d (%s)\n",
+		ksft_print_msg("child execveat() failed, rc=%d errno=%d (%s)\n",
 			       rc, errno, strerror(errno));
-		ksft_test_result_fail("%s\n", test_name);
-		exit(1);  /* should not reach here */
+		exit(errno);
 	}
 	/* Parent: wait for & check child's exit status. */
 	rc = waitpid(child, &status, 0);
@@ -226,11 +225,14 @@ static int check_execveat_pathmax(int root_dfd, const char *src, int is_script)
 	 * "If the command name is found, but it is not an executable utility,
 	 * the exit status shall be 126."), so allow either.
 	 */
-	if (is_script)
+	if (is_script) {
+		ksft_print_msg("Invoke script via root_dfd and relative filename\n");
 		fail += check_execveat_invoked_rc(root_dfd, longpath + 1, 0,
 						  127, 126);
-	else
+	} else {
+		ksft_print_msg("Invoke exec via root_dfd and relative filename\n");
 		fail += check_execveat(root_dfd, longpath + 1, 0);
+	}
 
 	return fail;
 }
Signature · 2 lines
BR,
Muhammad Usama Anjum
maintainer
#2 lore raw
Quoted 13 lines · Muhammad Usama Anjum
Quoted 4 lines · Kees Cook

Children processes were reporting their status, duplicating the parent's. Remove that, and add some additional details about the test execution.

Quoted 8 lines

---
Cc: Eric Biederman <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Muhammad Usama Anjum <[email protected]>
Cc: [email protected]
Cc: [email protected]

Quoted 2 lines

Applied to linux-kselftest fixes for the next rc.

thanks,
-- Shuah

author
#3 lore raw
Quoted 14 lines · Shuah Khan
Quoted 13 lines · Muhammad Usama Anjum
Quoted 12 lines · Kees Cook

Children processes were reporting their status, duplicating the parent's. Remove that, and add some additional details about the test execution.

---
Cc: Eric Biederman <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Muhammad Usama Anjum <[email protected]>
Cc: [email protected]
Cc: [email protected]

Quoted 4 lines
Quoted 2 lines

Applied to linux-kselftest fixes for the next rc.

This is already part of the execve tree...

Signature · 1 line
Kees Cook
maintainer
#4 lore raw
Quoted 15 lines · Kees Cook
Quoted 14 lines · Shuah Khan
Quoted 13 lines · Muhammad Usama Anjum
Quoted 12 lines · Kees Cook

Children processes were reporting their status, duplicating the parent's. Remove that, and add some additional details about the test execution.

---
Cc: Eric Biederman <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Muhammad Usama Anjum <[email protected]>
Cc: [email protected]
Cc: [email protected]

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Applied to linux-kselftest fixes for the next rc.

This is already part of the execve tree...

Thanks. I will go drop it.

thanks,
-- Shuah