summaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorJ. Bruce Fields2017-05-06 16:49:21 +0200
committerJ. Bruce Fields2017-08-25 04:12:48 +0200
commitb7571e4cd39ae860379138b883bc5f57a8553184 (patch)
tree331f475565a52362b1b1d83d89edd305f723fcf2 /fs/nfsd/nfs4xdr.c
parentnfsd4: define ->op_release for compound ops (diff)
downloadkernel-qcow2-linux-b7571e4cd39ae860379138b883bc5f57a8553184.tar.gz
kernel-qcow2-linux-b7571e4cd39ae860379138b883bc5f57a8553184.tar.xz
kernel-qcow2-linux-b7571e4cd39ae860379138b883bc5f57a8553184.zip
nfsd4: skip encoder in trivial error cases
Most encoders do nothing in the error case. But they can still screw things up in that case: most errors happen very early in rpc processing, possibly before argument fields are filled in and bounds-tested, so encoders that do anything other than immediately bail on error can easily crash in odd error cases. So just handle errors centrally most of the time to remove the chance of error. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 7d683e3aebf0..08badcf64554 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -4461,6 +4461,9 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
if (op->opnum == OP_ILLEGAL)
goto status;
+ if (op->status && opdesc &&
+ !(opdesc->op_flags & OP_NONTRIVIAL_ERROR_ENCODE))
+ goto status;
BUG_ON(op->opnum < 0 || op->opnum >= ARRAY_SIZE(nfsd4_enc_ops) ||
!nfsd4_enc_ops[op->opnum]);
encoder = nfsd4_enc_ops[op->opnum];