Linux Test Project
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Jan Polensky <japo@linux.ibm.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] thp04: Add ptrace support for CONFIG_PROC_MEM_FORCE_PTRACE=y
Date: Tue,  7 Jul 2026 16:43:04 +0000	[thread overview]
Message-ID: <20260707164304.4232-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20260707160024.216347-1-japo@linux.ibm.com>

Hi Jan,

On Tue, 7 Jul 2026 18:00:22 +0200, Jan Polensky wrote:
> thp04: Add ptrace support for CONFIG_PROC_MEM_FORCE_PTRACE=y

> - Restores lapi/mmap.h for MADV_* fallback definitions

The diff shows lapi/mmap.h was already present in the original file
and was not removed or re-added by this patch. "Restores" is
inaccurate here.

> +static void setup_ptrace_tracee(void)
> +{
> +	int status;
> +
> +	/* Test-loop state is initialized once and read-only afterwards. */
> +	child = SAFE_MMAP(NULL, sizeof(*child), PROT_READ | PROT_WRITE,
> +		MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> +	memset(child, 0, sizeof(*child));
> +	child->writefd = -1;
> +	child->readfd = -1;
> +
> +	tracee_pid = SAFE_FORK();
> +	if (!tracee_pid) {
> +		tracee_main();
> +		exit(0);
> +	}
> +
> +	TST_CHECKPOINT_WAIT(0);
> +
> +	SAFE_PTRACE(PTRACE_SEIZE, tracee_pid, NULL, NULL);
> +
> +	/*
> +	 * Tracee will run first iteration (madvise + check) and self-stop
> +	 * with raise(SIGSTOP). Wait for that SIGSTOP - this is iteration 0.
> +	 */
> +	SAFE_WAITPID(tracee_pid, &status, 0);

There is a race here. After TST_CHECKPOINT_WAKE(0) the tracee runs the
for(;;) body immediately and calls raise(SIGSTOP). If that raise()
fires before PTRACE_SEIZE executes in the parent, the SIGSTOP causes a
job-control stop (T state), not a ptrace-stop. PTRACE_SEIZE on an
already-T-stopped process does not generate a new ptrace event.

SAFE_WAITPID(..., 0) without WUNTRACED cannot see a job-control stop,
so the parent hangs indefinitely.

The comment "Parent will PTRACE_CONT us when ready - no checkpoint
needed" assumes PTRACE_SEIZE always wins the race, which is not
guaranteed, especially on a loaded system.

A second checkpoint (wake from parent after PTRACE_SEIZE completes,
wait in tracee before the first loop iteration) would close the window.

> +/*
>   * CVE-2017-1000405
>   *
> [...]
> + * Test Modes:
> + *
> + * PROC_MEM_ALWAYS: Direct writes to /proc/self/mem ...

The patch modifies this description block. The required opening for an
LTP high-level description block is /*\ (with a backslash), not /*.
The block is exported to the test catalog and must use the /*\ form.

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-07-07 16:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 16:00 [LTP] [PATCH v4 1/1] thp04: Add ptrace support for CONFIG_PROC_MEM_FORCE_PTRACE=y Jan Polensky
2026-07-07 16:43 ` linuxtestproject.agent [this message]
2026-07-09 14:35   ` [LTP] " Jan Polensky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260707164304.4232-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=japo@linux.ibm.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox