All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard-S6VGOU4v5edDinCvNWH78Q@public.gmane.org>
To: Enrico Weigelt <lkml-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
Cc: Linux Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: plan9 semantics on Linux - mount namespaces
Date: Wed, 14 Feb 2018 16:17:35 +0100	[thread overview]
Message-ID: <60748622.exvCVAzLTp@blindfold> (raw)
In-Reply-To: <4f620eb7-c00c-487b-2e06-8cc4c97af38c-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>

Enrico,

Am Mittwoch, 14. Februar 2018, 16:02:18 CET schrieb Enrico Weigelt:
> stat64("/etc/busybox.conf", {st_mode=S_IFREG|0644, st_size=198, ...}) = 0

busybox...

> brk(NULL)                               = 0x58000
> brk(0x79000)                            = 0x79000
> open("/etc/busybox.conf", O_RDONLY|O_LARGEFILE) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=198, ...}) = 0
> read(3, "[SUID]\n#lines starting with # ar"..., 1024) = 198
> read(3, "", 1024)                       = 0
> close(3)                                = 0
> getgid32()                              = 1
> setgid32(1)                             = 0
> setuid32(1)                             = 0
> geteuid32()                             = 1
> getegid32()                             = 1
> unshare(CLONE_NEWUTS|CLONE_NEWUSER)     = 0
> open("/proc/self/setgroups", O_WRONLY|O_LARGEFILE) = 3
> write(3, "deny", 4)                     = 4
> close(3)                                = 0
> open("/proc/self/uid_map", O_WRONLY|O_LARGEFILE) = 3
> write(3, "1 0 1", 5)                    = -1 EPERM (Operation not permitted)

This mapping looks broken.
Please report to busybox folks.

From taking a *very* quick look into busybox source, I suspect this should fix 
it:

diff --git a/util-linux/unshare.c b/util-linux/unshare.c
index 875e3f86e304..3f59cf4d27c2 100644
--- a/util-linux/unshare.c
+++ b/util-linux/unshare.c
@@ -350,9 +350,9 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
 		 * in that user namespace.
 		 */
 		xopen_xwrite_close(PATH_PROC_SETGROUPS, "deny");
-		sprintf(uidmap_buf, "%u 0 1", (unsigned)reuid);
+		sprintf(uidmap_buf, "0 %u 1", (unsigned)reuid);
 		xopen_xwrite_close(PATH_PROC_UIDMAP, uidmap_buf);
-		sprintf(uidmap_buf, "%u 0 1", (unsigned)regid);
+		sprintf(uidmap_buf, "0 %u 1", (unsigned)regid);
 		xopen_xwrite_close(PATH_PROC_GIDMAP, uidmap_buf);
 	} else
 	if (setgrp_str) {

Thanks,
//richard

-- 
sigma star gmbh - Eduard-Bodem-Gasse 6 - 6020 Innsbruck - Austria
ATU66964118 - FN 374287y

WARNING: multiple messages have this Message-ID (diff)
From: Richard Weinberger <richard@sigma-star.at>
To: Enrico Weigelt <lkml@metux.net>
Cc: Aleksa Sarai <asarai@suse.de>,
	Linux Containers <containers@lists.linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: plan9 semantics on Linux - mount namespaces
Date: Wed, 14 Feb 2018 16:17:35 +0100	[thread overview]
Message-ID: <60748622.exvCVAzLTp@blindfold> (raw)
In-Reply-To: <4f620eb7-c00c-487b-2e06-8cc4c97af38c@metux.net>

Enrico,

Am Mittwoch, 14. Februar 2018, 16:02:18 CET schrieb Enrico Weigelt:
> stat64("/etc/busybox.conf", {st_mode=S_IFREG|0644, st_size=198, ...}) = 0

busybox...

> brk(NULL)                               = 0x58000
> brk(0x79000)                            = 0x79000
> open("/etc/busybox.conf", O_RDONLY|O_LARGEFILE) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=198, ...}) = 0
> read(3, "[SUID]\n#lines starting with # ar"..., 1024) = 198
> read(3, "", 1024)                       = 0
> close(3)                                = 0
> getgid32()                              = 1
> setgid32(1)                             = 0
> setuid32(1)                             = 0
> geteuid32()                             = 1
> getegid32()                             = 1
> unshare(CLONE_NEWUTS|CLONE_NEWUSER)     = 0
> open("/proc/self/setgroups", O_WRONLY|O_LARGEFILE) = 3
> write(3, "deny", 4)                     = 4
> close(3)                                = 0
> open("/proc/self/uid_map", O_WRONLY|O_LARGEFILE) = 3
> write(3, "1 0 1", 5)                    = -1 EPERM (Operation not permitted)

This mapping looks broken.
Please report to busybox folks.

>From taking a *very* quick look into busybox source, I suspect this should fix 
it:

diff --git a/util-linux/unshare.c b/util-linux/unshare.c
index 875e3f86e304..3f59cf4d27c2 100644
--- a/util-linux/unshare.c
+++ b/util-linux/unshare.c
@@ -350,9 +350,9 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
 		 * in that user namespace.
 		 */
 		xopen_xwrite_close(PATH_PROC_SETGROUPS, "deny");
-		sprintf(uidmap_buf, "%u 0 1", (unsigned)reuid);
+		sprintf(uidmap_buf, "0 %u 1", (unsigned)reuid);
 		xopen_xwrite_close(PATH_PROC_UIDMAP, uidmap_buf);
-		sprintf(uidmap_buf, "%u 0 1", (unsigned)regid);
+		sprintf(uidmap_buf, "0 %u 1", (unsigned)regid);
 		xopen_xwrite_close(PATH_PROC_GIDMAP, uidmap_buf);
 	} else
 	if (setgrp_str) {

Thanks,
//richard

-- 
sigma star gmbh - Eduard-Bodem-Gasse 6 - 6020 Innsbruck - Austria
ATU66964118 - FN 374287y

  parent reply	other threads:[~2018-02-14 15:17 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13 22:12 plan9 semantics on Linux - mount namespaces Enrico Weigelt
     [not found] ` <0f058286-a432-379b-f559-f2fe713807ab-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-13 22:19   ` Enrico Weigelt
2018-02-13 22:19 ` Enrico Weigelt
     [not found]   ` <5633d335-3926-d98f-d6d7-948b1e2a0b2c-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-13 22:27     ` Aleksa Sarai
2018-02-13 22:27       ` Aleksa Sarai
2018-02-14  0:01       ` Enrico Weigelt
2018-02-14  0:01       ` Enrico Weigelt
     [not found]         ` <39b08c53-3449-3164-c1b1-44ac587dd4ea-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14  4:54           ` Aleksa Sarai
2018-02-14  4:54             ` Aleksa Sarai
2018-02-14 10:18             ` Enrico Weigelt
2018-02-14 10:18             ` Enrico Weigelt
     [not found]               ` <9c097fd9-3035-d5be-a829-fc18e7734f18-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14 10:24                 ` Aleksa Sarai
2018-02-14 10:24               ` Aleksa Sarai
2018-02-14 11:27                 ` Enrico Weigelt
2018-02-14 11:27                   ` Enrico Weigelt
     [not found]                   ` <24ddea73-5c84-e098-caae-8a4c14834cbd-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14 11:30                     ` Richard Weinberger
2018-02-14 11:30                   ` Richard Weinberger
     [not found]                     ` <CAFLxGvzxLP_UTQbwEY99bQfyftWzZHwaOP+WrzJ8099EKtbVLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-02-14 12:38                       ` Enrico Weigelt
2018-02-14 12:38                         ` Enrico Weigelt
2018-02-14 12:53                         ` Richard Weinberger
2018-02-14 14:03                           ` Enrico Weigelt
2018-02-14 14:03                             ` Enrico Weigelt
     [not found]                             ` <a2a6f189-008e-38f2-afcb-b9393d8d440a-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14 14:19                               ` Richard Weinberger
2018-02-14 14:19                                 ` Richard Weinberger
2018-02-14 15:02                                 ` Enrico Weigelt
     [not found]                                   ` <4f620eb7-c00c-487b-2e06-8cc4c97af38c-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14 15:17                                     ` Richard Weinberger [this message]
2018-02-14 15:17                                       ` Richard Weinberger
2018-02-14 17:21                                       ` Enrico Weigelt
2018-02-14 17:21                                       ` Enrico Weigelt
2018-02-14 17:50                                         ` Richard Weinberger
2018-02-14 18:01                                           ` Enrico Weigelt
     [not found]                                             ` <794929ce-0ecb-4c93-d51e-e94fcf749cfa-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14 18:12                                               ` Richard Weinberger
2018-02-14 18:12                                                 ` Richard Weinberger
2018-02-14 18:32                                                 ` Enrico Weigelt
2018-02-14 18:32                                                 ` Enrico Weigelt
2018-02-14 18:01                                           ` Enrico Weigelt
     [not found]                                         ` <e924b563-44c6-d678-a6cc-1181f4b820d5-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14 17:50                                           ` Richard Weinberger
2018-02-14 20:39                                           ` Aleksa Sarai
2018-02-14 20:39                                             ` Aleksa Sarai
2018-02-14 15:02                                 ` Enrico Weigelt
     [not found]                         ` <4864d279-9a3f-eaf4-c297-ea34be604e41-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.org>
2018-02-14 12:53                           ` Richard Weinberger
2018-02-16 18:26     ` Eric W. Biederman
2018-02-16 18:26       ` Eric W. Biederman

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=60748622.exvCVAzLTp@blindfold \
    --to=richard-s6vgou4v5eddincvnwh78q@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lkml-EcKl7qYKIbxeoWH0uzbU5w@public.gmane.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 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.