Commit 9e91edcd authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-4.2' of git://linux-nfs.org/~bfields/linux

Pull nfsd fixes from Bruce Fields.

* 'for-4.2' of git://linux-nfs.org/~bfields/linux:
  nfsd: do nfs4_check_fh in nfs4_check_file instead of nfs4_check_olstateid
  nfsd: Fix a file leak on nfsd4_layout_setlease failure
  nfsd: Drop BUG_ON and ignore SECLABEL on absent filesystem
parents ecf5fc6e 8fcd461d
...@@ -212,6 +212,7 @@ nfsd4_alloc_layout_stateid(struct nfsd4_compound_state *cstate, ...@@ -212,6 +212,7 @@ nfsd4_alloc_layout_stateid(struct nfsd4_compound_state *cstate,
BUG_ON(!ls->ls_file); BUG_ON(!ls->ls_file);
if (nfsd4_layout_setlease(ls)) { if (nfsd4_layout_setlease(ls)) {
fput(ls->ls_file);
put_nfs4_file(fp); put_nfs4_file(fp);
kmem_cache_free(nfs4_layout_stateid_cache, ls); kmem_cache_free(nfs4_layout_stateid_cache, ls);
return NULL; return NULL;
......
...@@ -4396,9 +4396,9 @@ laundromat_main(struct work_struct *laundry) ...@@ -4396,9 +4396,9 @@ laundromat_main(struct work_struct *laundry)
queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ); queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ);
} }
static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_ol_stateid *stp) static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
{ {
if (!fh_match(&fhp->fh_handle, &stp->st_stid.sc_file->fi_fhandle)) if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
return nfserr_bad_stateid; return nfserr_bad_stateid;
return nfs_ok; return nfs_ok;
} }
...@@ -4601,9 +4601,6 @@ nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags) ...@@ -4601,9 +4601,6 @@ nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags)
{ {
__be32 status; __be32 status;
status = nfs4_check_fh(fhp, ols);
if (status)
return status;
status = nfsd4_check_openowner_confirmed(ols); status = nfsd4_check_openowner_confirmed(ols);
if (status) if (status)
return status; return status;
...@@ -4690,6 +4687,9 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, ...@@ -4690,6 +4687,9 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
status = nfserr_bad_stateid; status = nfserr_bad_stateid;
break; break;
} }
if (status)
goto out;
status = nfs4_check_fh(fhp, s);
done: done:
if (!status && filpp) if (!status && filpp)
...@@ -4798,7 +4798,7 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_ ...@@ -4798,7 +4798,7 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_
status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
if (status) if (status)
return status; return status;
return nfs4_check_fh(current_fh, stp); return nfs4_check_fh(current_fh, &stp->st_stid);
} }
/* /*
......
...@@ -2143,6 +2143,7 @@ nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp, ...@@ -2143,6 +2143,7 @@ nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp,
#define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID | \ #define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID | \
FATTR4_WORD0_RDATTR_ERROR) FATTR4_WORD0_RDATTR_ERROR)
#define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID #define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID
#define WORD2_ABSENT_FS_ATTRS 0
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
static inline __be32 static inline __be32
...@@ -2171,7 +2172,7 @@ nfsd4_encode_security_label(struct xdr_stream *xdr, struct svc_rqst *rqstp, ...@@ -2171,7 +2172,7 @@ nfsd4_encode_security_label(struct xdr_stream *xdr, struct svc_rqst *rqstp,
{ return 0; } { return 0; }
#endif #endif
static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err) static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *bmval2, u32 *rdattr_err)
{ {
/* As per referral draft: */ /* As per referral draft: */
if (*bmval0 & ~WORD0_ABSENT_FS_ATTRS || if (*bmval0 & ~WORD0_ABSENT_FS_ATTRS ||
...@@ -2184,6 +2185,7 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err) ...@@ -2184,6 +2185,7 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err)
} }
*bmval0 &= WORD0_ABSENT_FS_ATTRS; *bmval0 &= WORD0_ABSENT_FS_ATTRS;
*bmval1 &= WORD1_ABSENT_FS_ATTRS; *bmval1 &= WORD1_ABSENT_FS_ATTRS;
*bmval2 &= WORD2_ABSENT_FS_ATTRS;
return 0; return 0;
} }
...@@ -2246,8 +2248,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, ...@@ -2246,8 +2248,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
BUG_ON(bmval2 & ~nfsd_suppattrs2(minorversion)); BUG_ON(bmval2 & ~nfsd_suppattrs2(minorversion));
if (exp->ex_fslocs.migrated) { if (exp->ex_fslocs.migrated) {
BUG_ON(bmval[2]); status = fattr_handle_absent_fs(&bmval0, &bmval1, &bmval2, &rdattr_err);
status = fattr_handle_absent_fs(&bmval0, &bmval1, &rdattr_err);
if (status) if (status)
goto out; goto out;
} }
...@@ -2286,8 +2287,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, ...@@ -2286,8 +2287,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
} }
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
if ((bmval[2] & FATTR4_WORD2_SECURITY_LABEL) || if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) ||
bmval[0] & FATTR4_WORD0_SUPPORTED_ATTRS) { bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) {
err = security_inode_getsecctx(d_inode(dentry), err = security_inode_getsecctx(d_inode(dentry),
&context, &contextlen); &context, &contextlen);
contextsupport = (err == 0); contextsupport = (err == 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment