public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: "Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>
Cc: util-linux@vger.kernel.org
Subject: Re: is one allowed to reenter a user namespace?
Date: Sun, 20 Jan 2013 16:47:32 -0800	[thread overview]
Message-ID: <87k3r7l5uj.fsf@xmission.com> (raw)
In-Reply-To: <20130120233621.GI17370@in.waw.pl> ("Zbigniew \=\?utf-8\?Q\?J\=C4\=99drzejewski-Szmek\=22's\?\= message of "Mon, 21 Jan 2013 00:36:22 +0100")

Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:

> Hi,
> when trying to enter a namespace, the behaviour wrt. to entering an
> existing namespace that the process is _already_ a part of is
> different for user names and all other namespaces. For user namespaces
> one gets EINVAL, while for other namespaces it succeeds. In other
> words, for user namespaces only, entering the namspace is not idempotent.
>
> # unshare --mount sleep 10000 &
>
> # nsenter --target=$(pgrep sleep) --mount /bin/true
> # nsenter --target=$(pgrep sleep) --ipc /bin/true
> # nsenter --target=$(pgrep sleep) --net /bin/true
> # nsenter --target=$(pgrep sleep) --uts /bin/true
> # nsenter --target=$(pgrep sleep) --user /bin/true
> nsenter: setns of 'ns/user' failed: Invalid argument
> (and the EINVAL is from setns())
>
> Is this difference intended?

Yes.

The definition of setns on a user namespace is that the process gains
all capabilities in that namespace.  As such if you could reenter your
current user namespace you would gain all capabilities which would
defeat the purpose of the capability bits.

Eric

      reply	other threads:[~2013-01-21  0:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-20 23:36 is one allowed to reenter a user namespace? Zbigniew Jędrzejewski-Szmek
2013-01-21  0:47 ` Eric W. Biederman [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=87k3r7l5uj.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=util-linux@vger.kernel.org \
    --cc=zbyszek@in.waw.pl \
    /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