From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 25 Jul 2016 09:54:45 -0500 From: "Serge E. Hallyn" To: "Michael Kerrisk (man-pages)" Cc: "Eric W. Biederman" , Serge Hallyn , Andrew Vagin , Linux API , Linux Containers , LKML , Alexander Viro , "criu@openvz.org" , linux-fsdevel , James Bottomley , Andrey Vagin Subject: Re: [PATCH 0/5 RFC] Add an interface to discover relationships between namespaces Message-ID: <20160725145445.GA19879@mail.hallyn.com> References: <1468520419-28220-1-git-send-email-avagin@openvz.org> <20160721210650.GA10989@outlook.office365.com> <1515f5f2-5a49-fcab-61f4-8b627d3ba3e2@gmail.com> <87lh0pg8jx.fsf@x220.int.ebiederm.org> <44ca0e41-dc92-45b1-2a6c-c41a048a072d@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <44ca0e41-dc92-45b1-2a6c-c41a048a072d@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: Quoting Michael Kerrisk (man-pages) (mtk.manpages@gmail.com): > Hi Eric, > > On 07/25/2016 03:18 PM, Eric W. Biederman wrote: > >"Michael Kerrisk (man-pages)" writes: > > > >>Hi Andrey, > >> > >>On 07/22/2016 08:25 PM, Andrey Vagin wrote: > >>>On Thu, Jul 21, 2016 at 11:48 PM, Michael Kerrisk (man-pages) > >>> wrote: > >>>>Hi Andrey, > >>>> > >>>> > >>>>On 07/21/2016 11:06 PM, Andrew Vagin wrote: > >>>>> > >>>>>On Thu, Jul 21, 2016 at 04:41:12PM +0200, Michael Kerrisk (man-pages) > >>>>>wrote: > >>>>>> > >>>>>>Hi Andrey, > >>>>>> > >>>>>>On 07/14/2016 08:20 PM, Andrey Vagin wrote: > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>> > >>>>>>Could you add here an of the API in detail: what do these FDs refer to, > >>>>>>and how do you use them to solve the use case? And could you you add > >>>>>>that info to the commit messages please. > >>>>> > >>>>> > >>>>>Hi Michael, > >>>>> > >>>>>A patch for man-pages is attached. It adds the following text to > >>>>>namespaces(7). > >>>>> > >>>>>Since Linux 4.X, the following ioctl(2) calls are supported for names‐ > >>>>>pace file descriptors. The correct syntax is: > >>>>> > >>>>> fd = ioctl(ns_fd, ioctl_type); > >>>>> > >>>>>where ioctl_type is one of the following: > >>>>> > >>>>>NS_GET_USERNS > >>>>> Returns a file descriptor that refers to an owning user names‐ > >>>>> pace. > >>>>> > >>>>>NS_GET_PARENT > >>>>> Returns a file descriptor that refers to a parent namespace. > >>>>> This ioctl(2) can be used for pid and user namespaces. For user > >>>>> namespaces, NS_GET_PARENT and NS_GET_USERNS have the same mean‐ > >>>>> ing. > >> > >>For each of the above, I think it is worth mentioning that the > >>close-on-exec flag is set for the returned file descriptor. > > > >Hmm. That is an odd default. > > Why do you say that? It's pretty common as the default for various > APIs that create new FDs these days. (There's of course a strong argument > that the original UNIX default was a design blunder...) > > >>>>> > >>>>>In addition to generic ioctl(2) errors, the following specific ones can > >>>>>occur: > >>>>> > >>>>>EINVAL NS_GET_PARENT was called for a nonhierarchical namespace. > >>>>> > >>>>>EPERM The requested namespace is outside of the current namespace > >>>>> scope. > >> > >>Perhaps add "and the caller does not have CAP_SYS_ADMIN" in the initial > >>user namespace"? > > > >Having looked at that bit of code I don't think capabilities really > >have a role to play. > > Yes, I caught up with that now. I await to see how this plays out > in the next patch version. Thanks - that had caught my eye but I hadn't had time to look into the justification for this. Hiding this kind of thing indeed seems wrong to me, unless there is a really good justification for it, i.e. a way to use that info in an exploit.