From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758744AbcHaClw (ORCPT ); Tue, 30 Aug 2016 22:41:52 -0400 Received: from h2.hallyn.com ([78.46.35.8]:48172 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752194AbcHaClt (ORCPT ); Tue, 30 Aug 2016 22:41:49 -0400 Date: Tue, 30 Aug 2016 21:41:46 -0500 From: "Serge E. Hallyn" To: Andrei Vagin Cc: "Eric W. Biederman" , containers@lists.linux-foundation.org, Serge Hallyn , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, James Bottomley , "Michael Kerrisk (man-pages)" , linux-fsdevel@vger.kernel.org, Alexander Viro Subject: Re: [PATCH 1/4] kernel: add a helper to get an owning user namespace for a namespace Message-ID: <20160831024146.GB21475@mail.hallyn.com> References: <1472252891-4963-1-git-send-email-avagin@openvz.org> <1472252891-4963-2-git-send-email-avagin@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1472252891-4963-2-git-send-email-avagin@openvz.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 26, 2016 at 04:08:08PM -0700, Andrei Vagin wrote: > From: Andrey Vagin > > Return -EPERM if an owning user namespace is outside of a process > current user namespace. > > v2: In a first version ns_get_owner returned ENOENT for init_user_ns. > This special cases was removed from this version. There is nothing > outside of init_user_ns, so we can return EPERM. > > Signed-off-by: Andrei Vagin > --- > fs/namespace.c | 6 ++++++ > include/linux/proc_ns.h | 1 + > include/linux/user_namespace.h | 7 +++++++ > ipc/namespace.c | 6 ++++++ > kernel/cgroup.c | 6 ++++++ > kernel/pid_namespace.c | 6 ++++++ > kernel/user_namespace.c | 24 ++++++++++++++++++++++++ > kernel/utsname.c | 6 ++++++ > net/core/net_namespace.c | 6 ++++++ > 9 files changed, 68 insertions(+) > > diff --git a/fs/namespace.c b/fs/namespace.c > index 491b8f3..f985817 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -3368,10 +3368,16 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns) > return 0; > } > > +static struct user_namespace *mntns_get_owner(struct ns_common *ns) > +{ > + return to_mnt_ns(ns)->user_ns; Hi - sorry to be pedantic here, but *_get_owner makes me think it will grab a reference too. A bit unfortunate, maybe it doesn't matter, but would mntns_owner(), netns_owner(), etc be better?