lkml.org 
[lkml]   [2017]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC v2 1/1] shiftfs: uid/gid shifting bind mount
From
Date
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.

James

\
 
 \ /
  Last update: 2017-02-21 23:24    [W:0.034 / U:29.012 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site