From: Kees Cook <kees.cook@canonical.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org
Subject: Re: [PATCH] Yama: turn process ancestry check into function
Date: Tue, 13 Jul 2010 17:30:49 -0700 [thread overview]
Message-ID: <20100714003049.GO6104@outflux.net> (raw)
In-Reply-To: <201007140019.o6E0J9gQ060582@www262.sakura.ne.jp>
On Wed, Jul 14, 2010 at 09:19:09AM +0900, Tetsuo Handa wrote:
> Kees Cook wrote:
> > +static int task_is_descendant(struct task_struct *parent,
> > + struct task_struct *child)
> > +{
> > + int rc = 0;
> > + struct task_struct *walker = child;
> > +
> > + if (!parent || !child)
> > + return 0;
>
> parent (== current) is !NULL and
> child (in original code) is !NULL.
> You can remove this check unless you are planning to call
> this function from other places.
I'd like the flexibility to call it with NULLs. But yes, at present, it
never will be NULL.
> > + if (mode == PTRACE_MODE_ATTACH &&
> > + ptrace_scope &&
> > + !task_is_descendant(current, child) &&
> > + !capable(CAP_SYS_PTRACE))
> > + rc = -EPERM;
>
> I don't know how heavy capable(CAP_SYS_PTRACE) is.
> But checking !capable(CAP_SYS_PTRACE) before
> !task_is_descendant(current, child) might be lighter.
That's the order I had before, but in looking at some of the other code, it
seemed like moving it to the end made more logical sense. Since checking
PTRACE attach isn't a common or time-sensitive operation, I figured trying
to tune it wasn't critical.
-Kees
--
Kees Cook
Ubuntu Security Team
next prev parent reply other threads:[~2010-07-14 0:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-13 17:33 Kees Cook
2010-07-14 0:19 ` Tetsuo Handa
2010-07-14 0:30 ` Kees Cook [this message]
2010-07-14 2:17 ` Serge E. Hallyn
2010-07-20 23:02 ` James Morris
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=20100714003049.GO6104@outflux.net \
--to=kees.cook@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
/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
Powered by JetHome