From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:41590 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751287AbcFACkP (ORCPT ); Tue, 31 May 2016 22:40:15 -0400 Date: Wed, 1 Jun 2016 03:40:00 +0100 From: Al Viro To: James Bottomley Cc: Djalal Harouni , Chris Mason , tytso@mit.edu, Serge Hallyn , 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 Subject: Re: [PATCH 1/1] shiftfs: uid/gid shifting bind mount Message-ID: <20160601023959.GF14480@ZenIV.linux.org.uk> References: <1464740984.7732.5.camel@HansenPartnership.com> <1464741093.7732.7.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464741093.7732.7.camel@HansenPartnership.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, May 31, 2016 at 08:31:33PM -0400, 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; > + > + /* note: violation of usual fs rules here: dentries are never > + * added with d_add. This is because we want no dentry cache > + * for shiftfs. All lookups proceed through the dentry cache > + * of the underlying filesystem, meaning we always see any > + * changes in the underlying */ > + > + 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); > + > + return NULL; This is utter crap. First of all, d_splice_alias() *WILL* hash them, so you get all the coherency problems, in spades. Moreover, if you did manage to avoid hashing, you would get something absolutely unusable. * no mounting of anything on top of that thing * performance shot to hell and that's just for starters. I hadn't looked into the locking and semantics issues - those would really depends upon how you would achieve that "no dentry cache" thing; again, right now that's *not* what your code is doing. PS: and then there's the choice of name. I mean, just try to say it over the phone several times in a row...