From: Oleg Nesterov <oleg@redhat.com>
To: Glauber Costa <glommer@parallels.com>
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
devel@openvz.org, kir@parallels.com,
Serge Hallyn <serge.hallyn@canonical.com>,
Michael Kerrisk <mtk.manpages@gmail.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Tejun Heo <tj@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: Re: [PATCH] allow a task to join a pid namespace
Date: Mon, 4 Jun 2012 18:51:17 +0200 [thread overview]
Message-ID: <20120604165117.GA13091@redhat.com> (raw)
In-Reply-To: <1338816828-25312-1-git-send-email-glommer@parallels.com>
On 06/04, Glauber Costa wrote:
>
> Currently, it is possible for a process to join existing
> net, uts and ipc namespaces. This patch allows a process to join an
> existing pid namespace as well.
I can't understand this patch... but probably I missed something,
I never really understood setns.
> +static int pidns_install(struct nsproxy *nsproxy, void *_ns)
> +{
> + struct pid *newpid;
> + struct pid_namespace *ns = _ns;
> +
> + if (is_container_init(current))
> + return -EINVAL;
> +
> + if (nsproxy->pid_ns != ns->parent)
> + return -EPERM;
At least you should also check that current is single-threaded,
I guess.
> +
> + if (task_pgrp(current) != task_pid(current))
> + return -EPERM;
> +
> + if (task_session(current) != task_pid(current))
> + return -EPERM;
Both checks are obviously racy without tasklist.
> + newpid = alloc_pid(ns);
> + if (!newpid)
> + return -ENOMEM;
Hmm. Doesn't this mean that pid_nr of this task (as it seen
in its current namespace) will be changed? This doesn't look
sane.
> + put_pid_ns(nsproxy->pid_ns);
> + nsproxy->pid_ns = get_pid_ns(ns);
> +
> + write_lock_irq(&tasklist_lock);
> + change_pid(current, PIDTYPE_PID, newpid);
> + change_pid(current, PIDTYPE_PGID, newpid);
> + change_pid(current, PIDTYPE_SID, newpid);
> + write_unlock_irq(&tasklist_lock);
Hmm. So, until the caller does switch_task_namespaces()
task_active_pid_ns(current) != current->nsproxy->pid_ns,
doesn't look very nice too.
I don't think this can be right. If nothing else, this breaks
it_real_fn().
Oleg.
next prev parent reply other threads:[~2012-06-04 16:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 13:33 [PATCH] allow a task to join a pid namespace Glauber Costa
2012-06-04 16:51 ` Oleg Nesterov [this message]
2012-06-05 9:30 ` Daniel Lezcano
2012-06-05 17:18 ` Eric W. Biederman
2012-06-05 9:36 ` Daniel Lezcano
2012-06-05 9:37 ` Glauber Costa
2012-06-05 10:00 ` [Devel] " Glauber Costa
2012-06-05 12:52 ` Daniel Lezcano
2012-06-05 12:53 ` Glauber Costa
2012-06-05 13:18 ` Daniel Lezcano
2012-06-05 17:39 ` Eric W. Biederman
2012-06-05 11:33 ` Glauber Costa
2012-06-06 18:29 ` Eric W. Biederman
2012-06-05 16:49 ` Eric W. Biederman
2012-06-06 8:54 ` Glauber Costa
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=20120604165117.GA13091@redhat.com \
--to=oleg@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=devel@openvz.org \
--cc=ebiederm@xmission.com \
--cc=glommer@parallels.com \
--cc=kir@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=serge.hallyn@canonical.com \
--cc=tj@kernel.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