From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965748AbcIWBXn convert rfc822-to-8bit (ORCPT ); Thu, 22 Sep 2016 21:23:43 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:40583 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965686AbcIWBXk (ORCPT ); Thu, 22 Sep 2016 21:23:40 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Andrei Vagin Cc: containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, James Bottomley , "Michael Kerrisk \(man-pages\)" , "W. Trevor King" , Alexander Viro , Serge Hallyn References: <1473148036-32630-1-git-send-email-avagin@openvz.org> Date: Thu, 22 Sep 2016 20:09:55 -0500 In-Reply-To: <1473148036-32630-1-git-send-email-avagin@openvz.org> (Andrei Vagin's message of "Tue, 6 Sep 2016 00:47:12 -0700") Message-ID: <87fuorbevw.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-XM-SPF: eid=1bnFDE-0001gU-Tx;;;mid=<87fuorbevw.fsf@x220.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=97.119.97.64;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/urvSBukRoJGp030XWE3Me5bAkKr2e340= X-SA-Exim-Connect-IP: 97.119.97.64 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa08 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa08 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Andrei Vagin X-Spam-Relay-Country: X-Spam-Timing: total 1167 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.9 (0.4%), b_tie_ro: 3.6 (0.3%), parse: 1.20 (0.1%), extract_message_metadata: 26 (2.3%), get_uri_detail_list: 3.0 (0.3%), tests_pri_-1000: 12 (1.0%), tests_pri_-950: 1.02 (0.1%), tests_pri_-900: 0.88 (0.1%), tests_pri_-400: 38 (3.3%), check_bayes: 37 (3.2%), b_tokenize: 13 (1.2%), b_tok_get_all: 12 (1.0%), b_comp_prob: 3.4 (0.3%), b_tok_touch_all: 4.4 (0.4%), b_finish: 1.12 (0.1%), tests_pri_0: 373 (32.0%), check_dkim_signature: 0.92 (0.1%), check_dkim_adsp: 4.4 (0.4%), tests_pri_500: 706 (60.5%), poll_dns_idle: 700 (60.0%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 0/4 v3] Add an interface to discover relationships between namespaces X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrei Vagin writes: > From: Andrey Vagin > > Each namespace has an owning user namespace and now there is not way > to discover these relationships. > > Pid and user namepaces are hierarchical. There is no way to discover > parent-child relationships too. > > Why we may want to know relationships between namespaces? > > One use would be visualization, in order to understand the running > system. Another would be to answer the question: what capability does > process X have to perform operations on a resource governed by namespace > Y? > > One more use-case (which usually called abnormal) is checkpoint/restart. > In CRIU we are going to dump and restore nested namespaces. > > There [1] was a discussion about which interface to choose to determing > relationships between namespaces. > > Eric suggested to add two ioctl-s [2]: >> Grumble, Grumble. I think this may actually a case for creating ioctls >> for these two cases. Now that random nsfs file descriptors are bind >> mountable the original reason for using proc files is not as pressing. >> >> One ioctl for the user namespace that owns a file descriptor. >> One ioctl for the parent namespace of a namespace file descriptor. > > Here is an implementaions of these ioctl-s. > > $ man man7/namespaces.7 > ... > Since Linux 4.X, the following ioctl(2) calls are supported for > namespace 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 > meaning. > > 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. > > [1] https://lkml.org/lkml/2016/7/6/158 > [2] https://lkml.org/lkml/2016/7/9/101 > > Changes for v2: > * don't return ENOENT for init_user_ns and init_pid_ns. There is nothing > outside of the init namespace, so we can return EPERM in this case too. >> The fewer special cases the easier the code is to get >> correct, and the easier it is to read. // Eric > > Changes for v3: > * rename ns->get_owner() to ns->owner(). get_* usually means that it > grabs a reference. > > Cc: "Eric W. Biederman" > Cc: James Bottomley > Cc: "Michael Kerrisk (man-pages)" > Cc: "W. Trevor King" > Cc: Alexander Viro > Cc: Serge Hallyn > Applied thanks. I didn't see any issues except your patch __ns_get_path was missing a mntput in the retry case. So I just fixed that. Eric