From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from h2.hallyn.com ([78.46.35.8]:48528 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932217AbcHaC4I (ORCPT ); Tue, 30 Aug 2016 22:56:08 -0400 Date: Tue, 30 Aug 2016 21:56:05 -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: <20160831025605.GA21788@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> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Aug 26, 2016 at 04:08:08PM -0700, Andrei Vagin wrote: > +struct ns_common *ns_get_owner(struct ns_common *ns) > +{ > + struct user_namespace *my_user_ns = current_user_ns(); > + struct user_namespace *owner, *p; > + > + /* See if the owner is in the current user namespace */ > + owner = p = ns->ops->get_owner(ns); > + for (;;) { > + if (!p) > + return ERR_PTR(-EPERM); > + if (p == my_user_ns) > + break; > + p = p->parent; > + } > + > + return &get_user_ns(owner)->ns; get_user_ns() bumps the owner's refcount. I don't see where this is being dropped, especially when ns_ioctl() uses it in the next patch.