[LTP] thp04: group runtime state and skip when /proc/self/mem writes are blocked
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Tue Sep 8 17:01:10 CEST 2026
Hi Jan,
On Tue Sep 8 13:13:28 2026 +0200, Jan Polensky wrote:
> thp04: group runtime state and skip when /proc/self/mem writes are blocked
--- [PATCH 1/3] ---
> Move thp04 runtime state from static globals into a heap-allocated
> struct thp_state. Group write_thp, read_thp, write_ptr, read_ptr,
> thp_size, writefd, readfd and fzsync_pair in one object instead of
> spreading them across file-scope variables.
>
> Also add a real /proc/self/mem write probe in setup(). If the write
This mixes two unrelated changes: refactoring file-scope state into a
struct and adding a runtime probe to skip when /proc/self/mem writes fail.
Please split these into separate patches or keep the static variables.
> + SAFE_MPROTECT((void *)state->write_thp, state->thp_size,
> + PROT_READ | PROT_WRITE);
> + *state->write_ptr = 0x12345678;
> + SAFE_MPROTECT((void *)state->write_thp, state->thp_size, PROT_READ);
Modifying state->write_thp here triggers COW and breaks the clean huge zero
page mapping before the test runs. Use a separate test buffer/mapping to
probe /proc/self/mem writes.
> + if (TST_RET == -1 && TST_ERR == EIO) {
> + tst_brk(TCONF,
> + "Direct writes to /proc/self/mem disabled "
> + "(CONFIG_PROC_MEM_FORCE_PTRACE=y)");
> + }
Do not split quoted string literals across lines.
--- [PATCH 2/3] ---
> @@ -1183,6 +1183,7 @@ ptrace09 ptrace09
> ptrace10 ptrace10
> ptrace11 ptrace11
>
> +ptrace12 ptrace12
> pwrite01 pwrite01
Move ptrace12 before the blank line so it stays grouped with the other
ptrace tests.
> + if (TST_RET == (ssize_t)sizeof(test_val)) {
> + tst_res(TCONF,
> + "Write to /proc/self/mem succeeded - "
> + "CONFIG_PROC_MEM_FORCE_PTRACE not enforcing ptrace checks");
> + return;
> + }
Do not split quoted string literals across lines.
--- [PATCH 3/3] ---
> @@ -1184,6 +1184,7 @@ ptrace10 ptrace10
> ptrace11 ptrace11
>
> ptrace12 ptrace12
> +ptrace13 ptrace13
> pwrite01 pwrite01
Place ptrace13 in the ptrace section before the blank line separating it
from pwrite.
> + for (i = 0; i < TEST_ITERATIONS; i++) {
> + if (*shared->test_ptr != shared->expected_val) {
> + tst_res(TFAIL,
> + "Iteration %d: expected 0x%x, got 0x%x",
> + i, shared->expected_val, *shared->test_ptr);
> + exit(1);
> + }
> +
> + raise(SIGSTOP);
> + }
> +
> + exit(0);
Calling raise(SIGSTOP) on the last iteration leaves exit(0) unreachable and
forces the parent to kill the tracee with SIGTERM. Skip raise(SIGSTOP) on the
final iteration so the child exits cleanly on PTRACE_CONT.
> + if (TST_RET == -1 && TST_ERR == EIO) {
> + SAFE_CLOSE(memfd);
> + SAFE_PTRACE(PTRACE_DETACH, tracee_pid, NULL, NULL);
> + SAFE_KILL(tracee_pid, SIGTERM);
> + tst_reap_children();
> + tracee_pid = 0;
> + tst_brk(TCONF,
> + "Write to /proc/pid/mem failed with EIO - "
> + "proc_mem.force_override=never disables FOLL_FORCE");
> + }
Do not split quoted string literals across lines.
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