Skip to contentSkip to conversation

execve05: add exit call when execve failed

PATCH Superseded [email protected] 2 participants 2 messages Jun 5

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 execve05: add exit call when execve failed

From: Yeguojin <[email protected]>

When execve_child loses its executable permission due to other exceptions, execve05 will degenerate into a fork bomb, which will then exhaust system resources and cause other system exceptions.

---
 testcases/kernel/syscalls/execve/execve05.c | 1 +
 1 file changed, 1 insertion(+)
testcases/kernel/syscalls/execve/execve05.c +1 -0
index 352c73c38..4b7eca9cf 100644
@@ -39,6 +39,7 @@ static void do_child(void)
 
 	TEST(execve(TEST_APP, argv, environ));
 	tst_res(TFAIL | TTERRNO, "execve() returned unexpected errno");
+	exit(EXIT_FAILURE);
 }
 
 static void verify_execve(void)
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Yeguojin,

testcases/kernel/syscalls/execve/execve05.c static void do_child(void) · line 42

Quoted 3 lines · Yeguojin

execve05: add exit call when execve failed

testcases/kernel/syscalls/execve/execve05.c +1 -0
+	exit(EXIT_FAILURE);

After tst_res(TFAIL | TTERRNO, ...) the result is already recorded by the framework. The child's exit code is used only to detect crashes or unexpected termination.

Once verify_execve() returns, the framework calls tst_reap_children(), which invokes check_child_status(). That function does:

  if (WEXITSTATUS(status))
      tst_brk(TBROK, "Invalid child (%i) exit value %i", ...);

So exit(EXIT_FAILURE) will produce a spurious TBROK on top of the already-reported TFAIL. The convention in LTP is to call exit(0) after reporting a result through tst_res() in a child process.

Verdict: Needs revision

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp