nfsd4_encode_readv() computes the in-page offset base = page_len & ~PAGE_MASK and passes it to nfsd_iter_read(), which writes the file data at that offset into *rq_next_page. After each operation rq_next_page is set to page_ptr + 1, so when the reply stream is mid-page the data lands one page ahead of where the payload accounting continues (in the current page at base). The client is then sent the stale tail of the current page - previous RPC payloads, since reply pages are reused without zeroing - instead of the file data: an info leak and corrupted READ results. Trigger: any compound where a READ follows an op that left the stream mid-page, e.g. [PUTFH, READ(100), READ(N)] or READDIR+READ. Place the data in the page the accounting is filling, buf->pages[page_len >> PAGE_SHIFT], instead of one page ahead. At an exact page boundary page_ptr is the empty page after the last full one and page_ptr + 1 is one page too far, so this covers that case too. Fixes: ed4a567a179e ("NFSD: Update rq_next_page between COMPOUND operations") Suggested-by: Chuck Lever Reported-by: Dairui Zhang Assisted-by: LLM Cc: stable@vger.kernel.org Signed-off-by: Dairui Zhang --- v1 -> v2: - Use buf->pages[page_len >> PAGE_SHIFT] for rq_next_page instead of page_ptr with an if (base) guard, per Chuck Lever's review: the guard only covered the mid-page case, while at an exact page boundary page_ptr is the empty page after the last full one and page_ptr + 1 is already two pages past it. The new form matches the accounting xdr_reserve_space_vec() extends. - v1: https://lore.kernel.org/linux-nfs/20260927094535.1745224-1-zhangdairui@gmail.com/ From code reading only - I haven't runtime-tested it, and this is my first patch to this list. If I've misread the flow somewhere, please tell me. --- fs/nfsd/nfs4xdr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 6a0a97d..e4b8285 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4933,6 +4933,14 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, __be32 zero = xdr_zero; __be32 nfserr; + /* + * The payload accounting continues at + * pages[page_len >> PAGE_SHIFT]; write the data there, not one + * page ahead. + */ + resp->rqstp->rq_next_page = xdr->buf->pages + + (xdr->buf->page_len >> PAGE_SHIFT); + nfserr = nfsd_iter_read(resp->rqstp, read->rd_fhp, read->rd_nf, read->rd_offset, &maxcount, base, &read->rd_eof); -- 2.53.0