public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Jim Newsome <jnewsome@torproject.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptrace: Allow other threads to access tracee
Date: Thu, 11 Mar 2021 16:21:23 +0100	[thread overview]
Message-ID: <20210311152123.GC15552@redhat.com> (raw)
In-Reply-To: <20210310205908.23447-1-jnewsome@torproject.org>

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.


  parent reply	other threads:[~2021-03-11 15:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 20:59 [PATCH] ptrace: Allow other threads to access tracee Jim Newsome
2021-03-11  1:31 ` kernel test robot
2021-03-11 15:21 ` Oleg Nesterov [this message]
2021-03-11 16:49   ` Jim Newsome
2021-03-12 17:07     ` Oleg Nesterov

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=20210311152123.GC15552@redhat.com \
    --to=oleg@redhat.com \
    --cc=jnewsome@torproject.org \
    --cc=linux-kernel@vger.kernel.org \
    /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