mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 07:00:48 +00:00
nfsd: open-code special directory-hardlink check
We allow the fh_verify caller to specify that any object *except* those of a given type is allowed, by passing a negative type. But only one caller actually uses it. Open-code that check in the one caller. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
3d2544b1e4
commit
7d818a7b8f
@ -61,7 +61,6 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
|
|||||||
static inline __be32
|
static inline __be32
|
||||||
nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
|
nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
|
||||||
{
|
{
|
||||||
/* Type can be negative when creating hardlinks - not to a dir */
|
|
||||||
if (type > 0 && (mode & S_IFMT) != type) {
|
if (type > 0 && (mode & S_IFMT) != type) {
|
||||||
if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
|
if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
|
||||||
return nfserr_symlink;
|
return nfserr_symlink;
|
||||||
@ -72,14 +71,6 @@ nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
|
|||||||
else
|
else
|
||||||
return nfserr_inval;
|
return nfserr_inval;
|
||||||
}
|
}
|
||||||
if (type < 0 && (mode & S_IFMT) == -type) {
|
|
||||||
if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
|
|
||||||
return nfserr_symlink;
|
|
||||||
else if (type == -S_IFDIR)
|
|
||||||
return nfserr_isdir;
|
|
||||||
else
|
|
||||||
return nfserr_notdir;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1632,10 +1632,12 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
|
|||||||
err = fh_verify(rqstp, ffhp, S_IFDIR, NFSD_MAY_CREATE);
|
err = fh_verify(rqstp, ffhp, S_IFDIR, NFSD_MAY_CREATE);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
err = fh_verify(rqstp, tfhp, -S_IFDIR, NFSD_MAY_NOP);
|
err = fh_verify(rqstp, tfhp, 0, NFSD_MAY_NOP);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
err = nfserr_isdir;
|
||||||
|
if (S_ISDIR(tfhp->fh_dentry->d_inode->i_mode))
|
||||||
|
goto out;
|
||||||
err = nfserr_perm;
|
err = nfserr_perm;
|
||||||
if (!len)
|
if (!len)
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user