From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932960AbdBVQlh (ORCPT ); Wed, 22 Feb 2017 11:41:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33438 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932458AbdBVQla (ORCPT ); Wed, 22 Feb 2017 11:41:30 -0500 Date: Wed, 22 Feb 2017 11:41:18 -0500 From: Vivek Goyal To: James Bottomley 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 , Amir Goldstein Subject: Re: [RFC v2 1/1] shiftfs: uid/gid shifting bind mount Message-ID: <20170222164118.GB14894@redhat.com> References: <1487637902.2337.47.camel@HansenPartnership.com> <1487638025.2337.49.camel@HansenPartnership.com> <20170221160649.GC28653@redhat.com> <1487715806.2373.15.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487715806.2373.15.camel@HansenPartnership.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 22 Feb 2017 16:41:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 21, 2017 at 05:23:26PM -0500, James Bottomley wrote: > On Tue, 2017-02-21 at 11:06 -0500, Vivek Goyal wrote: > > On Mon, Feb 20, 2017 at 04:47:05PM -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; > > > > newi needs to be initialized to NULL. Otherwise if a file does not > > exist, we try to call d_splice_alias() with uninitialized value of > > newi. > > > > This crashes for the new file creation case. > > I think you've still got an older version. The code around that region > should read: > > > > 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; > > newi = NULL; > if (!new->d_inode) > goto out; > > newi = shiftfs_new_inode(dentry->d_sb, new->d_inode->i_mode, new); > if (!newi) { > dput(new); > return ERR_PTR(-ENOMEM); > } > > out: > return d_splice_alias(newi, dentry); > > So newi is set to NULL before out is taken. I checked: this hunk did make it to the v2 patch. Aha.., you are right. I did not pay attention of newi=NULL in V2 and went on to provide feeback based on my V1 testing. Vivek