diff options
author | J. Bruce Fields <bfields@redhat.com> | 2013-02-28 15:51:49 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-04-03 11:47:53 -0400 |
commit | 9d313b17db965ae42137c5d4dd3063037544c4cd (patch) | |
tree | eaf39419bb8dcf2775570aa14ca12552655a69f1 /fs/nfsd | |
parent | b600de7ab9288eaf6126561203e0ae340828ab44 (diff) |
nfsd4: handle seqid-mutating open errors from xdr decoding
If a client sets an owner (or group_owner or acl) attribute on open for
create, and the mapping of that owner to an id fails, then we return
BAD_OWNER. But BAD_OWNER is a seqid-mutating error, so we can't
shortcut the open processing that case: we have to at least look up the
owner so we can find the seqid to bump.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 27 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 1 | ||||
-rw-r--r-- | fs/nfsd/xdr4.h | 1 |
3 files changed, 28 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index c7e4e8c28827..42c498ce9f0e 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -351,6 +351,10 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
351 | } | 351 | } |
352 | if (status) | 352 | if (status) |
353 | goto out; | 353 | goto out; |
354 | if (open->op_xdr_error) { | ||
355 | status = open->op_xdr_error; | ||
356 | goto out; | ||
357 | } | ||
354 | 358 | ||
355 | status = nfsd4_check_open_attributes(rqstp, cstate, open); | 359 | status = nfsd4_check_open_attributes(rqstp, cstate, open); |
356 | if (status) | 360 | if (status) |
@@ -417,6 +421,24 @@ out: | |||
417 | } | 421 | } |
418 | 422 | ||
419 | /* | 423 | /* |
424 | * OPEN is the only seqid-mutating operation whose decoding can fail | ||
425 | * with a seqid-mutating error (specifically, decoding of user names in | ||
426 | * the attributes). Therefore we have to do some processing to look up | ||
427 | * the stateowner so that we can bump the seqid. | ||
428 | */ | ||
429 | static __be32 nfsd4_open_omfg(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_op *op) | ||
430 | { | ||
431 | struct nfsd4_open *open = (struct nfsd4_open *)&op->u; | ||
432 | |||
433 | if (!seqid_mutating_err(ntohl(op->status))) | ||
434 | return op->status; | ||
435 | if (nfsd4_has_session(cstate)) | ||
436 | return op->status; | ||
437 | open->op_xdr_error = op->status; | ||
438 | return nfsd4_open(rqstp, cstate, open); | ||
439 | } | ||
440 | |||
441 | /* | ||
420 | * filehandle-manipulating ops. | 442 | * filehandle-manipulating ops. |
421 | */ | 443 | */ |
422 | static __be32 | 444 | static __be32 |
@@ -1244,8 +1266,11 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
1244 | * for example, if there is a miscellaneous XDR error | 1266 | * for example, if there is a miscellaneous XDR error |
1245 | * it will be set to nfserr_bad_xdr. | 1267 | * it will be set to nfserr_bad_xdr. |
1246 | */ | 1268 | */ |
1247 | if (op->status) | 1269 | if (op->status) { |
1270 | if (op->opnum == OP_OPEN) | ||
1271 | op->status = nfsd4_open_omfg(rqstp, cstate, op); | ||
1248 | goto encode_op; | 1272 | goto encode_op; |
1273 | } | ||
1249 | 1274 | ||
1250 | /* We must be able to encode a successful response to | 1275 | /* We must be able to encode a successful response to |
1251 | * this operation, with enough room left over to encode a | 1276 | * this operation, with enough room left over to encode a |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index a2720071f282..229b3ac246e1 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -804,6 +804,7 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) | |||
804 | open->op_iattr.ia_valid = 0; | 804 | open->op_iattr.ia_valid = 0; |
805 | open->op_openowner = NULL; | 805 | open->op_openowner = NULL; |
806 | 806 | ||
807 | open->op_xdr_error = 0; | ||
807 | /* seqid, share_access, share_deny, clientid, ownerlen */ | 808 | /* seqid, share_access, share_deny, clientid, ownerlen */ |
808 | READ_BUF(4); | 809 | READ_BUF(4); |
809 | READ32(open->op_seqid); | 810 | READ32(open->op_seqid); |
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 546f8983ecf1..be0a79d1dbcb 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h | |||
@@ -237,6 +237,7 @@ struct nfsd4_open { | |||
237 | u32 op_share_deny; /* request */ | 237 | u32 op_share_deny; /* request */ |
238 | u32 op_deleg_want; /* request */ | 238 | u32 op_deleg_want; /* request */ |
239 | stateid_t op_stateid; /* response */ | 239 | stateid_t op_stateid; /* response */ |
240 | __be32 op_xdr_error; /* see nfsd4_open_omfg() */ | ||
240 | u32 op_recall; /* recall */ | 241 | u32 op_recall; /* recall */ |
241 | struct nfsd4_change_info op_cinfo; /* response */ | 242 | struct nfsd4_change_info op_cinfo; /* response */ |
242 | u32 op_rflags; /* response */ | 243 | u32 op_rflags; /* response */ |