linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Aditya Kali <adityakali@google.com>
Cc: Serge Hallyn <serge.hallyn@ubuntu.com>, Tejun Heo <tj@kernel.org>,
	Li Zefan <lizefan@huawei.com>,
	cgroups@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [PATCH 0/5] RFC: CGroup Namespaces
Date: Fri, 25 Jul 2014 13:27:50 -0700	[thread overview]
Message-ID: <CALCETrW7im0CHp9z_n4ZaaiNVqz6hcXdXqFpT9iO3P4c92aJyg@mail.gmail.com> (raw)
In-Reply-To: <CAGr1F2GcAema-E2q6PFj=R0Z505iD7JshrMuMdfPTJ95wMiQMA@mail.gmail.com>

On Fri, Jul 25, 2014 at 12:29 PM, Aditya Kali <adityakali@google.com> wrote:
> Thank you for your review. I have tried to respond to both your emails here.
>
> On Thu, Jul 24, 2014 at 9:36 AM, Serge Hallyn <serge.hallyn@ubuntu.com> wrote:
>> 2. What would be the reprecussions of allowing cgroupns unshare so
>>    long as you have ns_capable(CAP_SYS_ADMIN) to the user_ns which
>>    created your current ns cgroup?  It'd be a shame if that wasn't
>>    on the roadmap.
>>
>
> Its certainly on the roadmap, just that some logistics were not clear
> at this time. As pointed out by Andy Lutomirski on [PATCH 5/5] of this
> series, if we allow cgroupns creation to ns_capable(CAP_SYS_ADMIN)
> processes, we may need some kind of explicit permission from the
> cgroup subsystem to allow this. One approach could be an explicit
> cgroup.may_unshare setting. Alternatively, the cgroup directory (which
> is going to become the cgroupns-root) ownership could also be used
> here. i.e., the process is ns_capable(CAP_SYS_ADMIN) && it owns the
> cgroup directory. There seems to be already a function that allows
> similar thing and might be sufficient:
>
> /**
>  * capable_wrt_inode_uidgid - Check nsown_capable and uid and gid mapped
>  * @inode: The inode in question
>  * @cap: The capability in question
>  *
>  * Return true if the current task has the given capability targeted at
>  * its own user namespace and that the given inode's uid and gid are
>  * mapped into the current user namespace.
>  */
> bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
>
> What do you think? We can enable this for non-init userns once this is
> decided on.
>

I think I'd rather it just check that it's owned by the userns owner
if we were going down that route.  But maybe there's a good reason to
do it this way.

>
>> 3. The un-namespaced view of /proc/self/cgroup from a sibling cgroupns
>>    makes me wonder whether it wouldn't be more appropriate to leave
>>    /proc/self/cgroup always un-filtered, and use /proc/self/nscgroup
>>    (or somesuch) to provide the namespaced view.  /proc/self/nscgroup
>>    would simply be empty (or say (invalid) or (unreachable)) from a
>>    sibling ns.  That will give criu and admin tools like lxc/docker all
>>    they need to do simple cgroup setup.
>>
>
> It may work for lxc/docker and new applications that use the new
> interface. But its difficult to change numerous existing user
> applications and libraries that depend on /proc/self/cgroup. Moreover,
> even with the new interface, /proc/self/cgroup will continue to leak
> system level cgroup information. And fixing this leak is critical to
> make the container migratable.
>
> Its easy to correctly handle the read of /proc/<pid>/cgroup from a
> sibling cgroupns. Instead of showing unfiltered view, we could just
> not show anything (same behavior when the cgroup hierarchy is not
> mounted). Will that be more acceptable? I can make that change in the
> next version of this series.
>
>


>>>   (5) setns() is not supported for cgroup namespace in the initial
>>>       version.
>>
>> This combined with the full-path reporting for peer ns cgroups could make
>> for fun antics when attaching to an existing container (since we'd have
>> to unshare into a new ns cgroup with the same roto as the container).
>> I understand you are implying this will be fixed soon though.
>>
>
> I am thinking the setns() will be only allowed if
> target_cgrpns->cgroupns_root is_descendant_of
> current_cgrpns->cgroupns_root. i.e., you will only be setns to a
> cgroup namespace which is rooted deeper in hierarchy than your own (in
> addition to checking capable_wrt_inode_uidgid(target_cgrpns_inode)).

I'm not sure why the capable_wrt_inode_uidgid is needed here -- I
imagine that the hierarchy check and the usual CAP_SYS_ADMIN check on
the cgroupns's userns would be sufficient.

>
> In addition to this, we need to decide whether its OK for setns() to
> also change the cgroup of the task. Consider following example:
>
> [A] ----> [B] ----> C
>     ----> D
>
> [A] and [B] are cgroupns-roots. Now, if a task in Cgroup D (which is
> under cgroupns [A]) attempts to setns() to cgroupns [B], then its
> cgroup should change from /A/D to /A/B. I am concerned about the
> side-effects this might cause. Though otherwise, this is a very useful
> feature for containers. One could argue that this is similar to
> setns() to a mount-namespace which is pivot_root'd somewhere else (in
> which case, the attaching task's root "/" moves implicitly with
> setns).

Off the top of my head, I think that making setns do this would be too
magical.  How about just requiring that you already be in (a
descendent of) the requested cgroupns's root cgroup if you try to
setns?

>
> Alternatively, we could only allow setns() if
> target_cgrpns->cgroupns_root == current->cgroup . I.e., taking above
> example again, if process in Cgroup D wants to setns() to cgroupns
> [B], then it will first need to move to Cgroup B, and only then the
> setns() will succeed. This makes sure that there is no implicit cgroup
> move.

I like this one, but I think that descendant cgroups should probably
be allowed, too.

--Andy

  reply	other threads:[~2014-07-25 20:28 UTC|newest]

Thread overview: 157+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <adityakali-cgroupns>
2014-07-17 19:52 ` [PATCH 0/5] RFC: CGroup Namespaces Aditya Kali
2014-07-17 19:52   ` [PATCH 1/5] kernfs: Add API to get generate relative kernfs path Aditya Kali
2014-07-24 15:10     ` Serge Hallyn
2014-07-17 19:52   ` [PATCH 2/5] sched: new clone flag CLONE_NEWCGROUP for cgroup namespace Aditya Kali
2014-07-24 17:01     ` Serge Hallyn
2014-07-31 19:48       ` Aditya Kali
2014-08-04 23:12         ` Serge Hallyn
2014-07-17 19:52   ` [PATCH 3/5] cgroup: add function to get task's cgroup on default hierarchy Aditya Kali
2014-07-24 16:59     ` Serge Hallyn
2014-07-17 19:52   ` [PATCH 4/5] cgroup: export cgroup_get() and cgroup_put() Aditya Kali
2014-07-24 17:03     ` Serge Hallyn
2014-07-17 19:52   ` [PATCH 5/5] cgroup: introduce cgroup namespaces Aditya Kali
2014-07-17 19:57     ` Andy Lutomirski
2014-07-17 20:55       ` Aditya Kali
2014-07-18 16:51         ` Andy Lutomirski
2014-07-18 18:51           ` Aditya Kali
2014-07-18 18:57             ` Andy Lutomirski
2014-07-21 22:11               ` Aditya Kali
2014-07-21 22:16                 ` Andy Lutomirski
2014-07-23 19:52                   ` Aditya Kali
2014-07-18 16:00   ` [PATCH 0/5] RFC: CGroup Namespaces Serge Hallyn
2014-07-24 16:10   ` Serge Hallyn
2014-07-24 16:36   ` Serge Hallyn
2014-07-25 19:29     ` Aditya Kali
2014-07-25 20:27       ` Andy Lutomirski [this message]
2014-07-29  4:51       ` Serge E. Hallyn
2014-07-29 15:08         ` Andy Lutomirski
2014-07-29 16:06           ` Serge E. Hallyn
2014-10-13 21:23 ` [PATCHv1 0/8] " Aditya Kali
2014-10-13 21:23   ` [PATCHv1 1/8] kernfs: Add API to generate relative kernfs path Aditya Kali
2014-10-16 16:07     ` Serge E. Hallyn
2014-10-13 21:23   ` [PATCHv1 2/8] sched: new clone flag CLONE_NEWCGROUP for cgroup namespace Aditya Kali
2014-10-16 16:08     ` Serge E. Hallyn
2014-10-13 21:23   ` [PATCHv1 3/8] cgroup: add function to get task's cgroup on default hierarchy Aditya Kali
2014-10-16 16:13     ` Serge E. Hallyn
2014-10-13 21:23   ` [PATCHv1 4/8] cgroup: export cgroup_get() and cgroup_put() Aditya Kali
2014-10-16 16:14     ` Serge E. Hallyn
2014-10-13 21:23   ` [PATCHv1 5/8] cgroup: introduce cgroup namespaces Aditya Kali
2014-10-16 16:37     ` Serge E. Hallyn
2014-10-24  1:03       ` Aditya Kali
2014-10-25  3:16         ` Serge E. Hallyn
2014-10-13 21:23   ` [PATCHv1 6/8] cgroup: restrict cgroup operations within task's cgroupns Aditya Kali
2014-10-17  9:28     ` Serge E. Hallyn
2014-10-22 19:06       ` Aditya Kali
2014-10-19  4:57     ` Eric W. Biederman
2014-10-13 21:23   ` [PATCHv1 7/8] cgroup: cgroup namespace setns support Aditya Kali
2014-10-16 21:12     ` Serge E. Hallyn
2014-10-16 21:17       ` Andy Lutomirski
2014-10-16 21:22       ` Aditya Kali
2014-10-16 21:47         ` Serge E. Hallyn
2014-10-19  5:23           ` Eric W. Biederman
2014-10-19 18:26             ` Andy Lutomirski
2014-10-20  4:55               ` Eric W.Biederman
2014-10-21  0:20                 ` Andy Lutomirski
2014-10-21  4:49                   ` Eric W. Biederman
2014-10-21  5:03                     ` Andy Lutomirski
2014-10-21  5:42                       ` Eric W. Biederman
2014-10-21  5:49                         ` Andy Lutomirski
2014-10-21 18:49                           ` Aditya Kali
2014-10-21 19:02                             ` Andy Lutomirski
2014-10-21 22:33                               ` Aditya Kali
2014-10-21 22:42                                 ` Andy Lutomirski
2014-10-22  0:46                                   ` Aditya Kali
2014-10-22  0:58                                     ` Andy Lutomirski
2014-10-22 18:37                                       ` Aditya Kali
2014-10-22 18:50                                         ` Andy Lutomirski
2014-10-22 19:42                                         ` Tejun Heo
2014-10-17  9:52     ` Serge E. Hallyn
2014-10-13 21:23   ` [PATCHv1 8/8] cgroup: mount cgroupns-root when inside non-init cgroupns Aditya Kali
2014-10-17 12:19     ` Serge E. Hallyn
2014-10-14 22:42   ` [PATCHv1 0/8] CGroup Namespaces Andy Lutomirski
2014-10-14 23:33     ` Aditya Kali
2014-10-19  4:54   ` Eric W. Biederman
2015-07-22 18:10     ` Vincent Batts
2014-10-31 19:18 ` [PATCHv2 0/7] " Aditya Kali
2014-10-31 19:18   ` [PATCHv2 1/7] kernfs: Add API to generate relative kernfs path Aditya Kali
2014-10-31 19:18   ` [PATCHv2 2/7] sched: new clone flag CLONE_NEWCGROUP for cgroup namespace Aditya Kali
2014-10-31 19:18   ` [PATCHv2 3/7] cgroup: add function to get task's cgroup on default hierarchy Aditya Kali
2014-10-31 19:18   ` [PATCHv2 4/7] cgroup: export cgroup_get() and cgroup_put() Aditya Kali
2014-10-31 19:18   ` [PATCHv2 5/7] cgroup: introduce cgroup namespaces Aditya Kali
2014-11-01  0:02     ` Andy Lutomirski
2014-11-01  0:58       ` Eric W. Biederman
2014-11-03 23:42         ` Aditya Kali
2014-11-03 23:40       ` Aditya Kali
2014-11-04  1:56     ` Aditya Kali
2014-10-31 19:19   ` [PATCHv2 6/7] cgroup: cgroup namespace setns support Aditya Kali
2014-10-31 19:19   ` [PATCHv2 7/7] cgroup: mount cgroupns-root when inside non-init cgroupns Aditya Kali
2014-11-01  0:07     ` Andy Lutomirski
2014-11-01  2:59       ` Eric W. Biederman
2014-11-01  3:29         ` Andy Lutomirski
2014-11-03 23:12       ` Aditya Kali
2014-11-03 23:15         ` Andy Lutomirski
2014-11-03 23:23           ` Aditya Kali
2014-11-03 23:48             ` Andy Lutomirski
2014-11-04  0:12               ` Aditya Kali
2014-11-04  0:17                 ` Andy Lutomirski
2014-11-04  0:49                   ` Aditya Kali
2014-11-04 13:57         ` Tejun Heo
2014-11-06 17:28           ` Aditya Kali
2014-11-01  1:09     ` Eric W. Biederman
2014-11-03 22:46       ` Aditya Kali
     [not found]       ` <CAGr1F2Hd_PS_AscBGMXdZC9qkHGRUp-MeQvJksDOQkRBB3RGoA@mail.gmail.com>
2014-11-03 22:56         ` Andy Lutomirski
2014-11-04 13:46         ` Tejun Heo
2014-11-04 15:00           ` Andy Lutomirski
2014-11-04 15:50             ` Serge E. Hallyn
2014-11-12 17:48               ` Aditya Kali
2014-11-04  1:59     ` Aditya Kali
2014-11-04 13:10   ` [PATCHv2 0/7] CGroup Namespaces Vivek Goyal
2014-11-06 17:33     ` Aditya Kali
2014-11-26 22:58       ` Richard Weinberger
2014-12-02 19:14         ` Aditya Kali
2014-12-05  1:55 ` [PATCHv3 0/8] " Aditya Kali
2014-12-05  1:55   ` [PATCHv3 1/8] kernfs: Add API to generate relative kernfs path Aditya Kali
2014-12-05  1:55   ` [PATCHv3 2/8] sched: new clone flag CLONE_NEWCGROUP for cgroup namespace Aditya Kali
2014-12-05  1:55   ` [PATCHv3 3/8] cgroup: add function to get task's cgroup on default hierarchy Aditya Kali
2014-12-05  1:55   ` [PATCHv3 4/8] cgroup: export cgroup_get() and cgroup_put() Aditya Kali
2014-12-05  1:55   ` [PATCHv3 5/8] cgroup: introduce cgroup namespaces Aditya Kali
2014-12-12  8:54     ` Zefan Li
2014-12-05  1:55   ` [PATCHv3 6/8] cgroup: cgroup namespace setns support Aditya Kali
2014-12-05  1:55   ` [PATCHv3 7/8] cgroup: mount cgroupns-root when inside non-init cgroupns Aditya Kali
2014-12-12  8:55     ` Zefan Li
2014-12-05  1:55   ` [PATCHv3 8/8] cgroup: Add documentation for cgroup namespaces Aditya Kali
2014-12-12  8:54     ` Zefan Li
2015-01-05 22:54       ` Aditya Kali
2014-12-14 23:05     ` Richard Weinberger
2015-01-05 22:48       ` Aditya Kali
2015-01-05 22:52         ` Richard Weinberger
2015-01-05 23:53           ` Eric W. Biederman
2015-01-06  0:07             ` Richard Weinberger
2015-01-06  0:10             ` Aditya Kali
2015-01-06  0:17               ` Richard Weinberger
2015-01-06 23:20                 ` Aditya Kali
2015-01-06 23:39                   ` Richard Weinberger
2015-01-07  9:28                   ` Richard Weinberger
2015-01-07 14:45                     ` Eric W. Biederman
2015-01-07 19:30                       ` Serge E. Hallyn
2015-01-07 22:14                         ` Eric W. Biederman
2015-01-07 22:45                           ` Tejun Heo
2015-01-07 23:02                             ` Eric W. Biederman
2015-01-07 23:06                               ` Tejun Heo
2015-01-07 23:09                                 ` Eric W. Biederman
2015-01-07 23:16                                   ` Tejun Heo
2015-01-07 23:27                                   ` Eric W. Biederman
2015-01-07 23:35                                     ` Tejun Heo
2015-02-11  3:46                                       ` Serge E. Hallyn
2015-02-11  4:09                                         ` Tejun Heo
2015-02-11  4:29                                           ` Serge E. Hallyn
2015-02-11  5:02                                             ` Eric W. Biederman
2015-02-11  5:17                                               ` Tejun Heo
2015-02-11  6:29                                                 ` Eric W. Biederman
2015-02-11 14:36                                                   ` Tejun Heo
2015-02-11 16:00                                                 ` Serge E. Hallyn
2015-02-11 16:03                                                   ` Tejun Heo
2015-02-11 16:18                                                     ` Serge E. Hallyn
2015-02-11  5:10                                             ` Tejun Heo
2015-01-07 18:57                     ` Aditya Kali
2014-12-05  3:20   ` [PATCHv3 0/8] CGroup Namespaces Aditya Kali

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=CALCETrW7im0CHp9z_n4ZaaiNVqz6hcXdXqFpT9iO3P4c92aJyg@mail.gmail.com \
    --to=luto@amacapital.net \
    --cc=adityakali@google.com \
    --cc=cgroups@vger.kernel.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@redhat.com \
    --cc=serge.hallyn@ubuntu.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;
as well as URLs for NNTP newsgroup(s).