Skip to content

Commit ed4a567

Browse files
committed
NFSD: Update rq_next_page between COMPOUND operations
A GETATTR with a large result can advance xdr->page_ptr without updating rq_next_page. If a splice READ follows that GETATTR in the COMPOUND, nfsd_splice_actor can start splicing at the wrong page. I've also seen READLINK and READDIR leave rq_next_page in an unmodified state. There are potentially a myriad of combinations like this, so play it safe: move the rq_next_page update to nfsd4_encode_operation. Signed-off-by: Chuck Lever <[email protected]>
1 parent ba21e20 commit ed4a567

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5438,6 +5438,12 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
54385438
release:
54395439
if (opdesc && opdesc->op_release)
54405440
opdesc->op_release(&op->u);
5441+
5442+
/*
5443+
* Account for pages consumed while encoding this operation.
5444+
* The xdr_stream primitives don't manage rq_next_page.
5445+
*/
5446+
rqstp->rq_next_page = xdr->page_ptr + 1;
54415447
}
54425448

54435449
/*
@@ -5506,9 +5512,6 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
55065512
p = resp->statusp;
55075513

55085514
*p++ = resp->cstate.status;
5509-
5510-
rqstp->rq_next_page = xdr->page_ptr + 1;
5511-
55125515
*p++ = htonl(resp->taglen);
55135516
memcpy(p, resp->tag, resp->taglen);
55145517
p += XDR_QUADLEN(resp->taglen);

0 commit comments

Comments
 (0)