linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Eugene Syromiatnikov <esyr@redhat.com>,
	Jan Kratochvil <jan.kratochvil@redhat.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Pedro Alves <palves@redhat.com>,
	Simon Marchi <simon.marchi@efficios.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RESEND2] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly
Date: Wed, 12 May 2021 15:36:16 +0200	[thread overview]
Message-ID: <20210512133615.GA19594@redhat.com> (raw)
In-Reply-To: <20210511180627.GB14488@redhat.com>

On 05/11, Oleg Nesterov wrote:
>
> On 05/11, Oleg Nesterov wrote:
> >
> > On 05/11, Linus Torvalds wrote:
> >
> > > That said, why this:
> > >
> > > > +       rcu_read_lock();
> > > > +       pid = task_pid_nr_ns(task, task_active_pid_ns(task->parent));
> > > > +       rcu_read_unlock();
> > >
> > > I don't see why the RCU read lock would be needed? task_pid_nr_ns()
> > > does any required locking itself, afaik.
> > >
> > > And even if it wasn't, this all happens with siglock held, can
> > > anything actually change.
> >
> > ... and with tasklist_lock held.
> >
> > Hmm. Linus, I am shy to admit I can't answer immediately, I'll recheck
> > tomorrow after sleep. But it seems you are right.
>
> most probably to protect task->parent, not sure, this was 6 month ago...
> but in this case we can use "current". I'll recheck.

Of course you are right, rcu_read_lock() is not needed. Plus we can use
task_pid_vnr() rather than task_pid_nr_ns(). I've sent v2.

Thanks again,

Oleg.


  reply	other threads:[~2021-05-12 13:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 16:56 [PATCH RESEND2] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly Oleg Nesterov
2021-05-11 17:28 ` Linus Torvalds
2021-05-11 17:53   ` Oleg Nesterov
2021-05-11 18:06     ` Oleg Nesterov
2021-05-12 13:36       ` Oleg Nesterov [this message]
2021-05-12 13:56         ` Mathieu Desnoyers
2021-05-12 14:38           ` 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=20210512133615.GA19594@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=esyr@redhat.com \
    --cc=jan.kratochvil@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mtk.manpages@gmail.com \
    --cc=palves@redhat.com \
    --cc=simon.marchi@efficios.com \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).