From: Oleg Nesterov <oleg@redhat.com>
To: Kees Cook <keescook@chromium.org>
Cc: Stijn Volckaert <Stijn.Volckaert@elis.ugent.be>,
Roland McGrath <roland@hack.frob.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-security-module <linux-security-module@vger.kernel.org>,
Stephen Smalley <sds@tycho.nsa.gov>,
Casey Schaufler <casey@schaufler-ca.com>,
John Johansen <john.johansen@canonical.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Subject: Re: [PATCH RFC] Allow introspection to already attached ptracer in __ptrace_may_access
Date: Tue, 6 Jan 2015 19:44:27 +0100 [thread overview]
Message-ID: <20150106184427.GA18153@redhat.com> (raw)
In-Reply-To: <CAGXu5jJWFKK1oJg0iyZtTKSSzXGyDD5B=iA3y7vvyayqhbOP5Q@mail.gmail.com>
On 01/05, Kees Cook wrote:
>
> I'm nervous to add this (or Oleg's suggestion) generally to
> __ptrace_may_access, as it would mean other LSMs would stop seeing
> access checks even when attached. It does seem silly to deny ptrace
> checks when already attached, but it does change the behavior here.
Same here.
> If the other LSM folks don't see a problem here, then it should live
> in the general case. Otherwise, I'm happy to add this check only in
> Yama.
In this case this check should probably go into ptracer_exception_found().
Btw it looks buggy... RCU protects ptrace_relation object, but not
relation->tracer (the final __put_task_struct() calls yama_task_free()
and frees task_struct without rcu gp).
This means that task_is_descendant(parent, tracer) can dereference the
already freed/unmapped parent, no?
And the usage of ->group_leader looks strange. tracee->group_leader can
point to nowhere if the task is already dead. In this case
"relation->tracee == tracee" can be false-positive (the same task_struct
can be re-allocated), but probably this is not that bad exactly because
the task is dead anyway.
prctl(PR_SET_PTRACER) looks strange too wrt group_leader. What if the caller
execs later? The comment says "we want process-level granularity of control",
but this is only true if the main thread does exec.
And get/out_task_struct(myself) look unneeded.
And it seems that task_is_descendant() doesn't need ->group_leader at all,
it could simply do
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;
rcu_read_lock();
do {
if (same_thread_group(walker, parent)) {
rc = 1;
break;
}
walker = rcu_dereference(walker->real_parent);
} while (walker != &init_task);
rcu_read_unlock();
return rc;
}
Oleg.
next prev parent reply other threads:[~2015-01-06 18:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-24 13:28 [PATCH RFC] Allow introspection to already attached ptracer in __ptrace_may_access Stijn Volckaert
2014-12-24 18:06 ` Oleg Nesterov
2015-01-05 23:47 ` Kees Cook
2015-01-06 0:17 ` Casey Schaufler
2015-01-06 9:07 ` Stijn Volckaert
2015-01-06 18:44 ` Oleg Nesterov [this message]
2015-01-08 10:40 ` Stijn Volckaert
2015-01-08 19:18 ` 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=20150106184427.GA18153@redhat.com \
--to=oleg@redhat.com \
--cc=Stijn.Volckaert@elis.ugent.be \
--cc=casey@schaufler-ca.com \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=roland@hack.frob.com \
--cc=sds@tycho.nsa.gov \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.