Re: [PATCH] CIFS: Fix ERR_PTR dereference in cifs_get_root

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 21 Aug 2011 12:22:51 -0400
Jeff Layton <jlayton@xxxxxxxxx> wrote:

> On Sun, 21 Aug 2011 19:30:15 +0400
> Pavel Shilovsky <piastryyy@xxxxxxxxx> wrote:
> 
> > move it to the beginning of the loop.
> > 
> > Signed-off-by: Pavel Shilovsky <piastryyy@xxxxxxxxx>
> > ---
> >  fs/cifs/cifsfs.c |   10 ++++++----
> >  1 files changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> > index 0435bb9..8b79122 100644
> > --- a/fs/cifs/cifsfs.c
> > +++ b/fs/cifs/cifsfs.c
> > @@ -559,6 +559,12 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
> >  		struct inode *dir = dentry->d_inode;
> >  		struct dentry *child;
> >  
> > +		if (!dir) {
> > +			dput(dentry);
> > +			dentry = ERR_PTR(-ENOENT);
> > +			break;
> > +		}
> > +
> >  		/* skip separators */
> >  		while (*s == sep)
> >  			s++;
> > @@ -574,10 +580,6 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
> >  		mutex_unlock(&dir->i_mutex);
> >  		dput(dentry);
> >  		dentry = child;
> > -		if (!dentry->d_inode) {
> > -			dput(dentry);
> > -			dentry = ERR_PTR(-ENOENT);
> > -		}
> >  	} while (!IS_ERR(dentry));
> >  	_FreeXid(xid);
> >  	kfree(full_path);
> 
> What exactly does this fix? The only possible thing I could see it is
> if sb->s_root was a negative dentry, and I'm not sure that would ever
> happen. Would it?
> 

Ahh, nevermind. I see the issue...

If IS_ERR(dentry) is true then we definitely don't want to try and
dereference the inode. This needs to go into 3.1 and stable as well.

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux