nfsd: fix EXDEV checking in rename
We again check for the EXDEV a little later on, so the first check is redundant. This check is also slightly racier, since a badly timed eviction from the export cache could leave us with the two fh_export pointers pointing to two different cache entries which each refer to the same underlying export. It's better to compare vfsmounts as the later check does, but that leaves a minor security hole in the case where the two exports refer to two different directories especially if (for example) they have different root-squashing options. So, compare ex_path.dentry too. Reported-by: Joe Habermann <joe.habermann@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
030d794bf4
commit
aa387d6ce1
1 changed files with 2 additions and 4 deletions
|
@ -1758,10 +1758,6 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
|
||||||
tdentry = tfhp->fh_dentry;
|
tdentry = tfhp->fh_dentry;
|
||||||
tdir = tdentry->d_inode;
|
tdir = tdentry->d_inode;
|
||||||
|
|
||||||
err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
|
|
||||||
if (ffhp->fh_export != tfhp->fh_export)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
err = nfserr_perm;
|
err = nfserr_perm;
|
||||||
if (!flen || isdotent(fname, flen) || !tlen || isdotent(tname, tlen))
|
if (!flen || isdotent(fname, flen) || !tlen || isdotent(tname, tlen))
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1802,6 +1798,8 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
|
||||||
host_err = -EXDEV;
|
host_err = -EXDEV;
|
||||||
if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
|
if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
|
||||||
goto out_dput_new;
|
goto out_dput_new;
|
||||||
|
if (ffhp->fh_export->ex_path.dentry != tfhp->fh_export->ex_path.dentry)
|
||||||
|
goto out_dput_new;
|
||||||
|
|
||||||
host_err = nfsd_break_lease(odentry->d_inode);
|
host_err = nfsd_break_lease(odentry->d_inode);
|
||||||
if (host_err)
|
if (host_err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue