Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>, stable@vger.kernel.org
Subject: [PATCH] SUNRPC: Honor page_base beyond the first page in xdr_buf_to_bvec()
Date: Fri,  6 Nov 2026 10:01:59 -0500	[thread overview]
Message-ID: <20261106150159.847600-1-cel@kernel.org> (raw)

xdr_buf_to_bvec() takes offset_in_page(page_base) but starts its
walk at pages[0], so the page index that page_base carries above
PAGE_SIZE is dropped. nfsd_direct_read() sets rq_res.page_base to
the pad below the file's DIO offset alignment. When that alignment
exceeds PAGE_SIZE, as with 8K to 64K logical blocks under xfs or
ext4 on a 4K-page NFSD, a direct READ whose pad reaches a full page
sends the page before the one that holds the data. The defect was
found by inspection, not reproduced.

Advance the page pointer by page_base >> PAGE_SHIFT before the walk.

Commit 2eb2b9358181 ("SUNRPC: Convert svc_tcp_sendmsg to use
bio_vecs directly") introduced the dropped shift, but no caller
produced a page_base of a page or more until direct READ.

This fix depends at run time on nfsd4_encode_operation() deriving
rq_next_page from page_base as well as page_len. Otherwise the READ
encoder accounts for one page fewer than xdr_buf_to_bvec() now
transmits, and the last page sent sits outside the release range
while TCP still references the page.

Fixes: d686e64e931c ("NFSD: Implement NFSD_IO_DIRECT for NFS READ")
Cc: <stable@vger.kernel.org> # v6.19+
Signed-off-by: Chuck Lever <cel@kernel.org>
---
 net/sunrpc/xdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 7353109fdbae..7eef50634175 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -161,7 +161,7 @@ int xdr_buf_to_bvec(struct bio_vec *bvec, unsigned int bvec_size,
 
 	if (xdr->page_len) {
 		unsigned int offset, len, remaining;
-		struct page **pages = xdr->pages;
+		struct page **pages = xdr->pages + (xdr->page_base >> PAGE_SHIFT);
 
 		offset = offset_in_page(xdr->page_base);
 		remaining = xdr->page_len;
-- 
2.56.0


             reply	other threads:[~2026-11-06 15:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 15:01 Chuck Lever [this message]
2026-11-06 19:13 ` [PATCH] SUNRPC: Honor page_base beyond the first page in xdr_buf_to_bvec() Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106150159.847600-1-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox