Skip to content

Commit 1aee915

Browse files
author
Al Viro
committed
nfsd: lock_rename() needs both directories to live on the same fs
... checking that after lock_rename() is too late. Incidentally, NFSv2 had no nfserr_xdev... Fixes: aa387d6 "nfsd: fix EXDEV checking in rename" Cc: [email protected] # v3.9+ Reviewed-by: Jeff Layton <[email protected]> Acked-by: Chuck Lever <[email protected]> Tested-by: Jeff Layton <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 94f6f05 commit 1aee915

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/nfsd/vfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,12 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
17881788
if (!flen || isdotent(fname, flen) || !tlen || isdotent(tname, tlen))
17891789
goto out;
17901790

1791+
err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
1792+
if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
1793+
goto out;
1794+
if (ffhp->fh_export->ex_path.dentry != tfhp->fh_export->ex_path.dentry)
1795+
goto out;
1796+
17911797
retry:
17921798
host_err = fh_want_write(ffhp);
17931799
if (host_err) {
@@ -1823,12 +1829,6 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
18231829
if (ndentry == trap)
18241830
goto out_dput_new;
18251831

1826-
host_err = -EXDEV;
1827-
if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
1828-
goto out_dput_new;
1829-
if (ffhp->fh_export->ex_path.dentry != tfhp->fh_export->ex_path.dentry)
1830-
goto out_dput_new;
1831-
18321832
if ((ndentry->d_sb->s_export_op->flags & EXPORT_OP_CLOSE_BEFORE_UNLINK) &&
18331833
nfsd_has_cached_files(ndentry)) {
18341834
close_cached = true;

0 commit comments

Comments
 (0)