[LTP] thp04: Add ptrace mode and fix tracee stop synchronization

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Thu Jul 9 20:56:57 CEST 2026


Hi Jan,

On Thu Jul 9 2026, Jan Polensky wrote:
> thp04: Add ptrace mode and fix tracee stop synchronization

The subject says "fix tracee stop synchronization". The original test
had no tracee or ptrace code at all -- this is entirely new logic.
"fix" suggests something broken was corrected. "add" would be more
accurate here.

> +static void tracee_main(void)
> +{
> ...
> +	/*
> +	 * Run indefinitely - parent controls termination via PTRACE_DETACH.
> +	 */

The actual termination sequence in run_proc_mem_ptrace_serialized() is
PTRACE_DETACH followed by SIGKILL. PTRACE_DETACH alone does not stop
the tracee; the parent then sends SIGKILL explicitly. The comment
should say "via SIGKILL (after PTRACE_DETACH)".

> +		if (*child->read_ptr != 0) {
> +			tst_res(TFAIL, "Huge zero page was polluted");
> +			child_cleanup();
> +			exit(1);
> +		}

> +	if (WEXITSTATUS(status) != 0) {
> +		/* Tracee reported result and exited early - already handled */
> +		tracee_pid = 0;
> +		free_child_state();
> +		return 1;
> +	}

> +		if (WIFEXITED(status)) {
> +			if (WEXITSTATUS(status) == 0)
> +				tst_brk(TBROK, "Tracee exited unexpectedly: %s",
> +						tst_strstatus(status));
> +
> +			/* Tracee reported result and exited, this is expected for TFAIL */
> +			tracee_exited = 1;
> +			break;
> +		}

The exit code is used to convey "tracee reported a failure" (exit 1)
vs "unexpected exit" (exit 0). LTP rule: never encode pass/fail as a
child exit code; use tst_res() only, and let the framework propagate
the result.

A cleaner approach: add a result_reported field (or similar) to
child_state, set it in the tracee before calling exit(0) on the
failure path, and check that flag in the parent after reaping. The
tracee always exits with 0; the parent distinguishes "reported failure"
from "unexpected exit" via the shared flag.

> +	char path[64];
> +	snprintf(path, sizeof(path), "/proc/%d/mem", tracee_pid);

Path buffers must use PATH_MAX, not a fixed-size literal.

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


More information about the ltp mailing list