diff mbox series

nfsd: Fix error cleanup path in nfsd_rename()

Message ID 20240318163209.26493-1-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series nfsd: Fix error cleanup path in nfsd_rename() | expand

Commit Message

Jan Kara March 18, 2024, 4:32 p.m. UTC
Commit a8b0026847b8 ("rename(): avoid a deadlock in the case of parents
having no common ancestor") added an error bail out path. However this
path does not drop the remount protection that has been acquired. Fix
the cleanup path to properly drop the remount protection.

Fixes: a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/nfsd/vfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jeff Layton March 18, 2024, 4:50 p.m. UTC | #1
On Mon, 2024-03-18 at 17:32 +0100, Jan Kara wrote:
> Commit a8b0026847b8 ("rename(): avoid a deadlock in the case of parents
> having no common ancestor") added an error bail out path. However this
> path does not drop the remount protection that has been acquired. Fix
> the cleanup path to properly drop the remount protection.
> 
> Fixes: a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/nfsd/vfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 6a9464262fae..2e41eb4c3cec 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1852,7 +1852,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
>  	trap = lock_rename(tdentry, fdentry);
>  	if (IS_ERR(trap)) {
>  		err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
> -		goto out;
> +		goto out_want_write;
>  	}
>  	err = fh_fill_pre_attrs(ffhp);
>  	if (err != nfs_ok)
> @@ -1922,6 +1922,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
>  	}
>  out_unlock:
>  	unlock_rename(tdentry, fdentry);
> +out_want_write:
>  	fh_drop_write(ffhp);
>  
>  	/*

Nice catch.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Chuck Lever March 18, 2024, 8:12 p.m. UTC | #2
On Mon, Mar 18, 2024 at 05:32:09PM +0100, Jan Kara wrote:
> Commit a8b0026847b8 ("rename(): avoid a deadlock in the case of parents
> having no common ancestor") added an error bail out path. However this
> path does not drop the remount protection that has been acquired. Fix
> the cleanup path to properly drop the remount protection.
> 
> Fixes: a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")
> Signed-off-by: Jan Kara <jack@suse.cz>

Al, Jan, let me know if you'd like me to take this through the
nfsd tree for v6.9-rc. If not:

Acked-by: Chuck Lever <chuck.lever@oracle.com>


> ---
>  fs/nfsd/vfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 6a9464262fae..2e41eb4c3cec 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1852,7 +1852,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
>  	trap = lock_rename(tdentry, fdentry);
>  	if (IS_ERR(trap)) {
>  		err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
> -		goto out;
> +		goto out_want_write;
>  	}
>  	err = fh_fill_pre_attrs(ffhp);
>  	if (err != nfs_ok)
> @@ -1922,6 +1922,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
>  	}
>  out_unlock:
>  	unlock_rename(tdentry, fdentry);
> +out_want_write:
>  	fh_drop_write(ffhp);
>  
>  	/*
> -- 
> 2.35.3
>
Jan Kara March 19, 2024, 1:53 p.m. UTC | #3
On Mon 18-03-24 16:12:17, Chuck Lever wrote:
> On Mon, Mar 18, 2024 at 05:32:09PM +0100, Jan Kara wrote:
> > Commit a8b0026847b8 ("rename(): avoid a deadlock in the case of parents
> > having no common ancestor") added an error bail out path. However this
> > path does not drop the remount protection that has been acquired. Fix
> > the cleanup path to properly drop the remount protection.
> > 
> > Fixes: a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")
> > Signed-off-by: Jan Kara <jack@suse.cz>
> 
> Al, Jan, let me know if you'd like me to take this through the
> nfsd tree for v6.9-rc. If not:
> 
> Acked-by: Chuck Lever <chuck.lever@oracle.com>

Yeah, I guess taking this through NFS tree is the best.

								Honza

> 
> 
> > ---
> >  fs/nfsd/vfs.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> > index 6a9464262fae..2e41eb4c3cec 100644
> > --- a/fs/nfsd/vfs.c
> > +++ b/fs/nfsd/vfs.c
> > @@ -1852,7 +1852,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> >  	trap = lock_rename(tdentry, fdentry);
> >  	if (IS_ERR(trap)) {
> >  		err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
> > -		goto out;
> > +		goto out_want_write;
> >  	}
> >  	err = fh_fill_pre_attrs(ffhp);
> >  	if (err != nfs_ok)
> > @@ -1922,6 +1922,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> >  	}
> >  out_unlock:
> >  	unlock_rename(tdentry, fdentry);
> > +out_want_write:
> >  	fh_drop_write(ffhp);
> >  
> >  	/*
> > -- 
> > 2.35.3
> > 
> 
> -- 
> Chuck Lever
>
Chuck Lever March 19, 2024, 3:18 p.m. UTC | #4
On Tue, Mar 19, 2024 at 02:53:54PM +0100, Jan Kara wrote:
> On Mon 18-03-24 16:12:17, Chuck Lever wrote:
> > On Mon, Mar 18, 2024 at 05:32:09PM +0100, Jan Kara wrote:
> > > Commit a8b0026847b8 ("rename(): avoid a deadlock in the case of parents
> > > having no common ancestor") added an error bail out path. However this
> > > path does not drop the remount protection that has been acquired. Fix
> > > the cleanup path to properly drop the remount protection.
> > > 
> > > Fixes: a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")
> > > Signed-off-by: Jan Kara <jack@suse.cz>
> > 
> > Al, Jan, let me know if you'd like me to take this through the
> > nfsd tree for v6.9-rc. If not:
> > 
> > Acked-by: Chuck Lever <chuck.lever@oracle.com>
> 
> Yeah, I guess taking this through NFS tree is the best.

I've pushed this to my nfsd-fixes branch, and will begin testing.


> 								Honza
> 
> > 
> > 
> > > ---
> > >  fs/nfsd/vfs.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> > > index 6a9464262fae..2e41eb4c3cec 100644
> > > --- a/fs/nfsd/vfs.c
> > > +++ b/fs/nfsd/vfs.c
> > > @@ -1852,7 +1852,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> > >  	trap = lock_rename(tdentry, fdentry);
> > >  	if (IS_ERR(trap)) {
> > >  		err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
> > > -		goto out;
> > > +		goto out_want_write;
> > >  	}
> > >  	err = fh_fill_pre_attrs(ffhp);
> > >  	if (err != nfs_ok)
> > > @@ -1922,6 +1922,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
> > >  	}
> > >  out_unlock:
> > >  	unlock_rename(tdentry, fdentry);
> > > +out_want_write:
> > >  	fh_drop_write(ffhp);
> > >  
> > >  	/*
> > > -- 
> > > 2.35.3
> > > 
> > 
> > -- 
> > Chuck Lever
> > 
> -- 
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
Al Viro March 22, 2024, 2:37 a.m. UTC | #5
On Mon, Mar 18, 2024 at 05:32:09PM +0100, Jan Kara wrote:
> Commit a8b0026847b8 ("rename(): avoid a deadlock in the case of parents
> having no common ancestor") added an error bail out path. However this
> path does not drop the remount protection that has been acquired. Fix
> the cleanup path to properly drop the remount protection.
> 
> Fixes: a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")
> Signed-off-by: Jan Kara <jack@suse.cz>

Acked-by: Al Viro <viro@zeniv.linux.org.uk>

Sorry, my fault.
diff mbox series

Patch

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 6a9464262fae..2e41eb4c3cec 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1852,7 +1852,7 @@  nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
 	trap = lock_rename(tdentry, fdentry);
 	if (IS_ERR(trap)) {
 		err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
-		goto out;
+		goto out_want_write;
 	}
 	err = fh_fill_pre_attrs(ffhp);
 	if (err != nfs_ok)
@@ -1922,6 +1922,7 @@  nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
 	}
 out_unlock:
 	unlock_rename(tdentry, fdentry);
+out_want_write:
 	fh_drop_write(ffhp);
 
 	/*