patches for 3.2
Subsystems (2)
Another v4 bug fix and some cleanup. I intend to commit these for 3.2 absent any objections.
--b.
PATCH 1/4 nfsd4: ignore WANT bits in open downgrade
We don't use WANT bits yet--and sending them can probably trigger a BUG() further down.
--- fs/nfsd/nfs4state.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nfsd/nfs4state.c +2 -0
@@ -3574,6 +3574,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,if (!access_valid (od->od_share_access, cstate->minorversion) || !deny_valid (od->od_share_deny))return nfserr_inval; +/* We don't yet support WANT bits: */ + od->od_share_access &=NFS4_SHARE_ACCESS_MASK ;nfs4_lock_state (); status = nfs4_preprocess_confirmed_seqid_op(cstate, od->od_seqid,
Signature · 1 line
1.7.4.1
PATCH 2/4 nfsd4: move access/deny validity checks to xdr code
In reply to J. Bruce FieldsI'd rather put more of these sorts of checks into standardized xdr decoders for the various types rather than have them cluttering up the core logic in nfs4proc.c and nfs4state.c.
--- fs/nfsd/nfs4state.c | 32 -------------------- fs/nfsd/nfs4xdr.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 39 deletions(-)
fs/nfsd/nfs4state.c +0 -32
@@ -2418,31 +2418,6 @@ find_file(struct inode *ino)return NULL ; } -static inline int access_valid (u32 x,u32 minorversion) -{ -if ((x &NFS4_SHARE_ACCESS_MASK ) <NFS4_SHARE_ACCESS_READ ) -return 0 ; -if ((x &NFS4_SHARE_ACCESS_MASK ) >NFS4_SHARE_ACCESS_BOTH ) -return 0 ; - x &= ~NFS4_SHARE_ACCESS_MASK ; -if (minorversion && x) { -if ((x &NFS4_SHARE_WANT_MASK ) >NFS4_SHARE_WANT_CANCEL ) -return 0 ; -if ((x &NFS4_SHARE_WHEN_MASK ) >NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED ) -return 0 ; - x &= ~(NFS4_SHARE_WANT_MASK |NFS4_SHARE_WHEN_MASK ); - } -if (x) -return 0 ; -return 1 ; -} - -static inline int deny_valid (u32 x) -{ -/* Note: unlike access bits, deny bits may be zero. */ -return x <=NFS4_SHARE_DENY_BOTH ; -} -/* * Called to check deny when READ with all zero stateid or * WRITE with all zero or all one stateid
@@ -2918,10 +2893,6 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfstruct nfs4_delegation *dp =NULL ;__be32 status; - status = nfserr_inval; -if (!access_valid (open->op_share_access, resp->cstate.minorversion) - || !deny_valid (open->op_share_deny)) - goto out;/* * Lookup file; if found, lookup stateid and check open request, * and check for delegations in the process of being recalled.
@@ -3571,9 +3542,6 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, (int )cstate->current_fh.fh_dentry->d_name.len, cstate->current_fh.fh_dentry->d_name.name); -if (!access_valid (od->od_share_access, cstate->minorversion) - || !deny_valid (od->od_share_deny)) -return nfserr_inval;/* We don't yet support WANT bits: */ od->od_share_access &=NFS4_SHARE_ACCESS_MASK ;
fs/nfsd/nfs4xdr.c +73 -7
100 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 3/4 nfsd4: move name-length checks to xdr
In reply to J. Bruce FieldsAgain, these checks are better in the xdr code.
--- fs/nfsd/nfs4state.c | 24 ++---------------------- fs/nfsd/nfs4xdr.c | 45 ++++++++++++++++++++++++++++++--------------- fs/nfsd/xdr4.h | 3 +-- 3 files changed, 33 insertions(+), 39 deletions(-)
fs/nfsd/nfs4state.c +2 -22
@@ -1189,17 +1189,6 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir,return clp; } -static int check_name (struct xdr_netobj name) -{ -if (name.len ==0 ) -return 0 ; -if (name.len >NFS4_OPAQUE_LIMIT ) { -dprintk ("NFSD: check_name: name too long(%d)!\n" , name.len); -return 0 ; - } -return 1 ; -} -static void add_to_unconfirmed (struct nfs4_client *clp,unsigned int strhashval) {
@@ -1442,7 +1431,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, __func__, rqstp, exid, exid->clname.len, exid->clname.data, addr_str, exid->flags, exid->spa_how); -if (!check_name (exid->clname) || (exid->flags & ~EXCHGID4_FLAG_MASK_A )) +if (exid->flags & ~EXCHGID4_FLAG_MASK_A )return nfserr_inval;/* Currently only support SP4_NONE */
@@ -1992,19 +1981,13 @@ __be32 nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_setclientid *setclid) { - struct xdr_netobj clname = { - .len = setclid->se_namelen, - .data = setclid->se_name, - }; + struct xdr_netobj clname = setclid->se_name;nfs4_verifier clverifier = setclid->se_verf;unsigned int strhashval;struct nfs4_client *conf, *unconf, *new;__be32 status;char dname[HEXDIR_LEN ]; -if (!check_name (clname)) -return nfserr_inval; - status =nfs4_make_rec_clidname (dname, &clname);if (status)return status;
@@ -2523,9 +2506,6 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,struct nfs4_openowner *oo =NULL ;__be32 status; -if (!check_name (open->op_owner)) -return nfserr_inval; -if (STALE_CLIENTID (&open->op_clientid))return nfserr_stale_clientid;
fs/nfsd/nfs4xdr.c +30 -15
72 lines not on this page · raw message
fs/nfsd/xdr4.h +1 -2
@@ -317,8 +317,7 @@ struct nfsd4_setattr {struct nfsd4_setclientid {nfs4_verifier se_verf;/* request */ -u32 se_namelen;/* request */ -char * se_name;/* request */ +struct xdr_netobj se_name;u32 se_callback_prog;/* request */ u32 se_callback_netid_len;/* request */ char * se_callback_netid_val;/* request */
Signature · 1 line
1.7.4.1
PATCH 4/4 nfsd4: more robust ignoring of WANT bits in OPEN
In reply to J. Bruce FieldsMask out the WANT bits right at the start instead of on each use.
--- fs/nfsd/nfs4proc.c | 3 +++ fs/nfsd/nfs4state.c | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-)
fs/nfsd/nfs4proc.c +3 -0
@@ -315,6 +315,9 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,if (open->op_create && open->op_claim_type !=NFS4_OPEN_CLAIM_NULL )return nfserr_inval; +/* We don't yet support WANT bits: */ + open->op_share_access &=NFS4_SHARE_ACCESS_MASK ; +/* * RFC5661 18.51.3 * Before RECLAIM_COMPLETE done, server should deny new lock
fs/nfsd/nfs4state.c +2 -3
@@ -2345,8 +2345,7 @@ static inline __be32 init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_ stp->st_file = fp; stp->st_access_bmap =0 ; stp->st_deny_bmap =0 ; -__set_bit (open->op_share_access & ~NFS4_SHARE_WANT_MASK , - &stp->st_access_bmap); +__set_bit (open->op_share_access, &stp->st_access_bmap);__set_bit (open->op_share_deny, &stp->st_deny_bmap); stp->st_openstp =NULL ;return nfs_ok;
@@ -2690,7 +2689,7 @@ nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh,static __be32 nfs4_upgrade_open (struct svc_rqst *rqstp,struct nfs4_file *fp,struct svc_fh *cur_fh,struct nfs4_ol_stateid *stp,struct nfsd4_open *open) { -u32 op_share_access = open->op_share_access & ~NFS4_SHARE_WANT_MASK ; +u32 op_share_access = open->op_share_access;bool new_access;__be32 status;
Signature · 1 line
1.7.4.1