From: Roland McGrath <roland@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Chris Wright <chrisw@sous-sol.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] ptrace: ptrace_attach: check PF_KTHREAD + exit_state instead of ->mm
Date: Sun, 10 May 2009 16:11:12 -0700 (PDT) [thread overview]
Message-ID: <20090510231112.5DABDFC35D@magilla.sf.frob.com> (raw)
In-Reply-To: Oleg Nesterov's message of Saturday, 9 May 2009 20:43:03 +0200 <20090509184303.GA10396@redhat.com>
> > On second look, what does __ptrace_may_access() need task_lock() for anyway?
>
> Just for get_dumpable(task->mm), I think.
Ah. That's really only for using the mm, right? i.e. it could be using
get_task_mm() instead. set_dumpable() does not use task_lock() to
synchronize the actual changes that affect get_dumpable().
> OK, so this change is not purely cosmetic as I thought.
Right.
> We can fix this in many ways. We can extract the ->cred and ->mm checks
> from __ptrace_may_access() into another helper which is called before
> write_lock(tasklist), and then call security_ptrace_may_access under tasklist.
> Or we can do get_task_mm() in advance and call __ptrace_may_access() without
> task_lock().
get_task_mm() makes sense to me. It seems like those checks being under
the tasklist_lock (i.e. the lock governing ptrace attach) might matter.
> Or, perhaps, we can just check ->ptrace before __ptrace_may_access()
> lockless (just to prevent the scenario above), and then check it again
> under tasklist? This looks like a simplest option.
Doesn't that still have a possible race with PTRACE_TRACEME? If
ptrace_traceme() runs between the lockless check and the lock-taking, we
want PTRACE_ATTACH to fail without calling security_ptrace_may_access().
Maybe the cred mutex should be excluding that here anyway.
Thanks,
Roland
prev parent reply other threads:[~2009-05-10 23:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-05 22:47 Oleg Nesterov
2009-05-05 23:47 ` Andrew Morton
2009-05-05 23:57 ` Oleg Nesterov
2009-05-06 1:24 ` Andrew Morton
2009-05-06 2:06 ` Roland McGrath
2009-05-06 4:56 ` Oleg Nesterov
2009-05-06 5:03 ` Andrew Morton
2009-05-06 7:08 ` Christoph Hellwig
2009-05-06 7:41 ` Ingo Molnar
2009-05-06 2:02 ` Roland McGrath
2009-05-06 4:52 ` Oleg Nesterov
2009-05-07 5:51 ` Roland McGrath
2009-05-09 18:43 ` Oleg Nesterov
2009-05-10 23:11 ` Roland McGrath [this message]
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=20090510231112.5DABDFC35D@magilla.sf.frob.com \
--to=roland@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chrisw@sous-sol.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@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
all inboxes | Powered by JetHome®