lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 7 Mar 2011 11:58:41 -0500
From:	"J. Bruce  Fields" <bfields@...ldses.org>
To:	NeilBrown <neilb@...e.de>
Cc:	Jesper Juhl <jj@...osbits.net>, linux-nfs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Trond Myklebust <Trond.Myklebust@...app.com>
Subject: Re: [PATCH] NFSD, VFS: Remove dead code in nfsd_rename()

On Sun, Mar 06, 2011 at 04:52:42PM +1100, NeilBrown wrote:
> On Sun, 6 Mar 2011 00:30:35 +0100 (CET) Jesper Juhl <jj@...osbits.net> wrote:
> 
> > Currently we have the following code in fs/nfsd/vfs.c::nfsd_rename() :
> > 
> > 	...
> > 	host_err = nfsd_break_lease(odentry->d_inode);
> > 	if (host_err)
> > 		goto out_drop_write;
> > 	if (ndentry->d_inode) {
> > 		host_err = nfsd_break_lease(ndentry->d_inode);
> > 		if (host_err)
> > 			goto out_drop_write;
> > 	}
> > 	if (host_err)
> > 		goto out_drop_write;
> > 	...
> > 
> > 'host_err' is guaranteed to be 0 by the time we test 'ndentry->d_inode'. 
> > If 'host_err' becomes != 0 inside the 'if' statement, then we goto 
> > 'out_drop_write'. So, after the 'if' statement there is no way that 
> > 'host_err' can be anything but 0, so the test afterwards is just dead 
> > code.
> > This patch removes the dead code.
> 
> I would probably have gone for:
> 
>   host_err = nfsd_break_lease(odentry->d_inode);
>   if (!host_err && ndentry->d_inode)
>         host_err = nfsd_break_lease(ndentry->d_inode);
>   if (host_err)
>         goto out_drop_write;
> 
> or even
>   host_err = nfsd_break_lease(odentry->d_inode);
>   if (ndentry->d_inode)
>         host_err = hosterr ?: nfsd_break_lease(ndentry->d_inode);
>   if (host_err)
>         goto out_drop_write;
> 
> 
> but it is largely a matter of taste.  I agree there is redundant code there
> and your's is a suitable fix.

Yeah, works for me.  Thanks for catching that; queueing up for 2.6.39.

--b.

> 
> NeilBrown
> 
> > 
> > Signed-off-by: Jesper Juhl <jj@...osbits.net>
> > ---
> >  vfs.c |    2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> > index da1d970..9cc626b 100644
> > --- a/fs/nfsd/vfs.c
> > +++ b/fs/nfsd/vfs.c
> > @@ -1749,8 +1749,6 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> >  		if (host_err)
> >  			goto out_drop_write;
> >  	}
> > -	if (host_err)
> > -		goto out_drop_write;
> >  	host_err = vfs_rename(fdir, odentry, tdir, ndentry);
> >  	if (!host_err) {
> >  		host_err = commit_metadata(tfhp);
> > 
> > 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ