Util-Linux package development
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: util-linux@vger.kernel.org
Cc: ebiederm@xmission.com
Subject: [PATCH] nsenter: fix ability to enter unprivileged containers
Date: Mon, 18 Apr 2016 08:26:32 -0400	[thread overview]
Message-ID: <1460982392.2452.6.camel@HansenPartnership.com> (raw)

If you enter it first, you lose privilege for subsequent namespace
enters,see issue

https://github.com/karelzak/util-linux/issues/315

The fix is to enter the user namespace last of all.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
index d8690db..1525f15 100644
--- a/sys-utils/nsenter.c
+++ b/sys-utils/nsenter.c
@@ -52,13 +52,13 @@ static struct namespace_file {
 	 * first.  This gives an unprivileged user the potential to
 	 * enter the other namespaces.
 	 */
-	{ .nstype = CLONE_NEWUSER,  .name = "ns/user", .fd = -1 },
 	{ .nstype = CLONE_NEWCGROUP,.name = "ns/cgroup", .fd = -1 },
 	{ .nstype = CLONE_NEWIPC,   .name = "ns/ipc",  .fd = -1 },
 	{ .nstype = CLONE_NEWUTS,   .name = "ns/uts",  .fd = -1 },
 	{ .nstype = CLONE_NEWNET,   .name = "ns/net",  .fd = -1 },
 	{ .nstype = CLONE_NEWPID,   .name = "ns/pid",  .fd = -1 },
 	{ .nstype = CLONE_NEWNS,    .name = "ns/mnt",  .fd = -1 },
+	{ .nstype = CLONE_NEWUSER,  .name = "ns/user", .fd = -1 },
 	{ .nstype = 0, .name = NULL, .fd = -1 }
 };
 

             reply	other threads:[~2016-04-18 12:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 12:26 James Bottomley [this message]
2016-04-18 14:33 ` [PATCH] nsenter: fix ability to enter unprivileged containers Yuriy M. Kaminskiy
2016-04-18 15:51   ` Yuriy M. Kaminskiy
2016-04-18 15:37 ` James Bottomley
2016-04-18 15:50   ` James Bottomley
2016-04-18 17:11   ` Karel Zak
2016-04-18 17:28     ` James Bottomley
2016-04-18 18:26       ` Eric W. Biederman
2016-04-18 20:56         ` James Bottomley
2016-04-18 21:31           ` Eric W. Biederman
2016-04-22  9:05           ` Karel Zak
2016-04-18 19:40     ` James Bottomley

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=1460982392.2452.6.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=ebiederm@xmission.com \
    --cc=util-linux@vger.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