From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932512AbdBPP4h (ORCPT ); Thu, 16 Feb 2017 10:56:37 -0500 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:34370 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932143AbdBPP4e (ORCPT ); Thu, 16 Feb 2017 10:56:34 -0500 Message-ID: <1487260590.2944.21.camel@HansenPartnership.com> Subject: Re: [RFC 1/1] shiftfs: uid/gid shifting bind mount From: James Bottomley To: Vivek Goyal Cc: Djalal Harouni , Chris Mason , Theodore Tso , Josh Triplett , "Eric W. Biederman" , Andy Lutomirski , Seth Forshee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Dongsu Park , David Herrmann , Miklos Szeredi , Alban Crequy , Al Viro , "Serge E. Hallyn" , Phil Estes Date: Thu, 16 Feb 2017 07:56:30 -0800 In-Reply-To: <20170215203441.GA22585@redhat.com> References: <1486235880.2484.17.camel@HansenPartnership.com> <1486235972.2484.19.camel@HansenPartnership.com> <20170215203441.GA22585@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-02-15 at 15:34 -0500, Vivek Goyal wrote: > On Sat, Feb 04, 2017 at 11:19:32AM -0800, James Bottomley wrote: > > [..] > > +static struct dentry *shiftfs_lookup(struct inode *dir, struct > > dentry *dentry, > > + unsigned int flags) > > +{ > > + struct dentry *real = dir->i_private, *new; > > + struct inode *reali = real->d_inode, *newi; > > + const struct cred *oldcred, *newcred; > > + > > + inode_lock(reali); > > + oldcred = shiftfs_new_creds(&newcred, dentry->d_sb); > > + new = lookup_one_len(dentry->d_name.name, real, dentry > > ->d_name.len); > > + shiftfs_old_creds(oldcred, &newcred); > > + inode_unlock(reali); > > + > > + if (IS_ERR(new)) > > + return new; > > + > > + dentry->d_fsdata = new; > > + > > + if (!new->d_inode) > > + return NULL; > > + > > + newi = shiftfs_new_inode(dentry->d_sb, new->d_inode > > ->i_mode, new); > > + if (!newi) { > > + dput(new); > > + return ERR_PTR(-ENOMEM); > > + } > > + > > + d_splice_alias(newi, dentry); > > Hi James, > > Should it be "return d_splice_alias()" so that if we find an alias it > is returned back to caller and passed in dentry can be freed. Though > I don't know in what cases alias can be found. And if alias is found > how do we make sure alias_dentry->d_fsdata is pointing to new (real > dentry). It probably should be for the sake of the pattern. In our case I don't think we can have any root aliases because the root dentry is always pinned in the cache, so cache lookup should always find it. James