Re: [PATCH] ptrace: Allow other threads to access tracee

From: Oleg Nesterov
Date: Thu Mar 11 2021 - 10:22:10 EST


On 03/10, Jim Newsome wrote:
>
> @@ -238,7 +238,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
> * be changed by us so it's not changing right after this.
> */
> read_lock(&tasklist_lock);
> - if (child->ptrace && child->parent == current) {
> + if (child->ptrace && same_thread_group(child->parent, current)) {

Cough... it is not that simple.

Just suppose that 2 threads call ptrace(tracee) at the same time. Say, the 1st
thread does PTRACE_CONT while the 2nd thread tries to change the registers.

Oleg.