linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Richard Guy Briggs <rgb@redhat.com>
Cc: John Johansen <john.johansen@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Eric Paris <eparis@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] apparmor: remove the "task" arg from may_change_ptraced_domain()
Date: Wed, 18 Dec 2013 21:19:41 +0100	[thread overview]
Message-ID: <20131218201940.GA9694@redhat.com> (raw)
In-Reply-To: <20131218194338.GB23692@madcap2.tricolour.ca>

On 12/18, Richard Guy Briggs wrote:
>
> Bcc: rgb@redhat.com
> Subject: Re: [PATCH] apparmor: remove the "task" arg from
>  may_change_ptraced_domain()
> Reply-To:
> In-Reply-To: <20130926132519.GY13968@madcap2.tricolour.ca>

The subject is empty ;) I changed it to match the above.

> On 13/09/26, Richard Guy Briggs wrote:
> > On Tue, Sep 24, 2013 at 06:44:42PM +0200, Oleg Nesterov wrote:
> > > On 09/23, Richard Guy Briggs wrote:
> > > >
> > > > On Mon, Sep 16, 2013 at 04:20:35PM +0200, Oleg Nesterov wrote:
> > > > > Unless task == current ptrace_parent(task) is not safe even under
> > > > > rcu_read_lock() and most of the current users are not right.
> > > >
> > > > Could you point to an explanation of this?
> > >
> > > If this task exits before rcu_read_lock() ->parent can point to the
> > > already freed/reused memory.
> >
> > Ok, understood.  So even though the task may have exited, the task
> > struct pointer is still valid, but not the contents of the task struct
> > to which it points.
>
> [The thread also relates to the patch
> 	"pid: get ppid pid_t of task in init_pid_ns safely"
> in which sys_getppid() (which appears safe) is replaced with something that
> references the init_pid_ns rather than current's pid_ns.]
>
> So, in the general case, that call is not safe, and we should at least
> remove the task_struct argument.

I changed my mind, please see the recent discussion with Paul:

	http://marc.info/?t=138626281900001

instead we should document why ptrace_parent() is safe without pid_alive().

I hope that the change in apparmor was fine anyway.


Otherwise I can't understand your email, at least right now... I do not
know how/where audit uses parent/real_parent.

But yes, unless tsk == current, the usage of tsk->*parent is not safe even
under rcu_read_lock() unless you verify that this task was not unhashed.

ptrace_parent() is safe because it checks ->ptrace. Previously I thought
we should not rely on this, but the additional pid_alive() looks ugly so
it would be better to simply document this. I'll send the patch.

Oleg.


  reply	other threads:[~2013-12-18 20:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 19:43 Richard Guy Briggs
2013-12-18 20:19 ` Oleg Nesterov [this message]
2013-12-20  4:36   ` [PATCH] apparmor: remove the "task" arg from may_change_ptraced_domain() Richard Guy Briggs
2013-12-20  6:22     ` John Johansen
2013-12-20 17:59     ` Oleg Nesterov
  -- strict thread matches above, loose matches on Subject: below --
2013-09-16 14:20 Oleg Nesterov
2013-09-16 15:10 ` Oleg Nesterov
2013-09-16 17:01 ` John Johansen
2013-09-23 21:52 ` Richard Guy Briggs
2013-09-24 16:44   ` Oleg Nesterov
2013-09-26 13:25     ` Richard Guy Briggs

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=20131218201940.GA9694@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=eparis@redhat.com \
    --cc=john.johansen@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rgb@redhat.com \
    /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).