]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
SUNRPC: Tighten bounds checking in svc_rqst_replace_page
authorChuck Lever <chuck.lever@oracle.com>
Thu, 26 Feb 2026 14:47:34 +0000 (09:47 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 30 Mar 2026 01:25:09 +0000 (21:25 -0400)
svc_rqst_replace_page() builds the Reply buffer by advancing
rq_next_page through the response page range. The bounds
check validates rq_next_page against the full rq_pages array,
but the valid range for rq_next_page is

  [rq_respages, rq_page_end].

Use those bounds instead.

This is correct today because rq_respages and rq_page_end
both point into rq_pages, and it prepares for a subsequent
change that separates the Reply page array from rq_pages.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/svc.c

index d8ccb8e4b5c26792bba476232d7c57962d9ea178..f7ec02457328f49fbef64d0aef819006937fcaef 100644 (file)
@@ -934,11 +934,11 @@ svc_set_num_threads(struct svc_serv *serv, unsigned int min_threads,
 EXPORT_SYMBOL_GPL(svc_set_num_threads);
 
 /**
- * svc_rqst_replace_page - Replace one page in rq_pages[]
+ * svc_rqst_replace_page - Replace one page in rq_respages[]
  * @rqstp: svc_rqst with pages to replace
  * @page: replacement page
  *
- * When replacing a page in rq_pages, batch the release of the
+ * When replacing a page in rq_respages, batch the release of the
  * replaced pages to avoid hammering the page allocator.
  *
  * Return values:
@@ -947,8 +947,8 @@ EXPORT_SYMBOL_GPL(svc_set_num_threads);
  */
 bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page)
 {
-       struct page **begin = rqstp->rq_pages;
-       struct page **end = &rqstp->rq_pages[rqstp->rq_maxpages];
+       struct page **begin = rqstp->rq_respages;
+       struct page **end = rqstp->rq_page_end;
 
        if (unlikely(rqstp->rq_next_page < begin || rqstp->rq_next_page > end)) {
                trace_svc_replace_page_err(rqstp);