svcrdma: use rc_pageoff for memcpy byte offset
Subsystems (4)
Chuck Lever
maintainerPATCH 1/3 svcrdma: use rc_pageoff for memcpy byte offset
From: Joshua Rogers <[email protected]>
svc_rdma_copy_inline_range added rc_curpage (page index) to the page base instead of the byte offset rc_pageoff. Use rc_pageoff so copies land within the current page.
X-Cc: [email protected]
--- net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_rw.c +1 -1
@@ -848,7 +848,7 @@ static int svc_rdma_copy_inline_range(struct svc_rqst *rqstp, head->rc_page_count++; dst =page_address (rqstp->rq_pages[head->rc_curpage]); -memcpy (dst + head->rc_curpage, src + offset, page_len); +memcpy ((unsigned char *)dst + head->rc_pageoff, src + offset, page_len); head->rc_readbytes += page_len; head->rc_pageoff += page_len;
Signature · 1 line
2.51.0
Chuck Lever
maintainerPATCH 2/3 svcrdma: return 0 on success from svc_rdma_copy_inline_range
From: Joshua Rogers <[email protected]>
The function comment specifies 0 on success and -EINVAL on invalid parameters. Make the tail return 0 after a successful copy loop.
X-Cc: [email protected]
--- net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_rw.c +1 -1
@@ -860,7 +860,7 @@ static int svc_rdma_copy_inline_range(struct svc_rqst *rqstp, offset += page_len; } -return -EINVAL ; +return 0 ; }/**
Signature · 1 line
2.51.0
Chuck Lever
maintainerPATCH 3/3 svcrdma: bound check rq_pages index in inline path
In reply to Chuck LeverFrom: Joshua Rogers <[email protected]>
svc_rdma_copy_inline_range indexed rqstp->rq_pages[rc_curpage] without verifying rc_curpage stays within the allocated page array. Add guards before the first use and after advancing to a new page.
X-Cc: [email protected]
--- net/sunrpc/xprtrdma/svc_rdma_rw.c | 3 +++ 1 file changed, 3 insertions(+)
net/sunrpc/xprtrdma/svc_rdma_rw.c +3 -0
@@ -841,6 +841,9 @@ static int svc_rdma_copy_inline_range(struct svc_rqst *rqstp,for (page_no =0 ; page_no < numpages; page_no++) {unsigned int page_len; +if (head->rc_curpage >= rqstp->rq_maxpages) +return -EINVAL ; + page_len = min_t(unsigned int, remaining,PAGE_SIZE - head->rc_pageoff);
Signature · 1 line
2.51.0
Apologies: is it possible to slightly change the commit msg to include "Found with ZeroPath"? As this bug was, indeed, found with a tool called ZeroPath. If not, it's OK, thought I'd ask.
Thank you.
Quoted 40 lines · Chuck Lever
From: Joshua Rogers [email protected]
svc_rdma_copy_inline_rangeaddedrc_curpage(page index) to the page base instead of the byte offsetrc_pageoff. Userc_pageoffso copies land within the current page.Fixes 8e122582680c ("svcrdma: Move svc_rdma_read_info::ri_pageno to struct svc_rdma_recv_ctxt")X-Cc: [email protected]
Signed-off-by Joshua Rogers [email protected]Signed-off-by Chuck Lever [email protected]---
net/sunrpc/xprtrdma/svc_rdma_rw.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)net/sunrpc/xprtrdma/svc_rdma_rw.c +1
-1@@ -848,7 +848,7 @@ static int svc_rdma_copy_inline_range(struct svc_rqst *rqstp, head->rc_page_count++; dst =page_address (rqstp->rq_pages[head->rc_curpage]); -memcpy (dst + head->rc_curpage, src + offset, page_len); +memcpy ((unsigned char *)dst + head->rc_pageoff, src + offset, page_len);
head->rc_readbytes+=page_len;
head->rc_pageoff+=page_len;--
2.51.0
Chuck Lever
maintainerQuoted 3 lines · Joshua Rogers
Apologies: is it possible to slightly change the commit msg to include "Found with ZeroPath"? As this bug was, indeed, found with a tool called ZeroPath. If not, it's OK, thought I'd ask.
Thank you.
Patch description in my tree now reads:
svcrdma: use rc_pageoff for memcpy byte offset
svc_rdma_copy_inline_range added rc_curpage (page index) to the page base instead of the byte offset rc_pageoff. Use rc_pageoff so copies land within the current page.
Found by ZeroPath (https://zeropath.com)
Quoted 43 lines · Chuck Lever
Quoted 41 lines
From: Joshua Rogers [email protected]
svc_rdma_copy_inline_rangeaddedrc_curpage(page index) to the page base instead of the byte offsetrc_pageoff. Userc_pageoffso copies land within the current page.Fixes 8e122582680c ("svcrdma: Move svc_rdma_read_info::ri_pageno to struct svc_rdma_recv_ctxt")X-Cc: [email protected]
Signed-off-by Joshua Rogers [email protected]Signed-off-by Chuck Lever [email protected]---
net/sunrpc/xprtrdma/svc_rdma_rw.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)net/sunrpc/xprtrdma/svc_rdma_rw.c +1
-1@@ -848,7 +848,7 @@ static int svc_rdma_copy_inline_range(struct svc_rqst *rqstp, head->rc_page_count++; dst =page_address (rqstp->rq_pages[head->rc_curpage]); -memcpy (dst + head->rc_curpage, src + offset, page_len); +memcpy ((unsigned char *)dst + head->rc_pageoff, src + offset, page_len);
head->rc_readbytes+=page_len;
head->rc_pageoff+=page_len;--
2.51.0
Signature · 1 line
Chuck Lever
Sounds reasonable, or "Found by Joshua Rogers with ZeroPath(https://zeropath.com)", but I have no problem with either.
thx
Quoted 63 lines · Chuck Lever
Quoted 3 lines · Joshua Rogers
Apologies: is it possible to slightly change the commit msg to include "Found with ZeroPath"? As this bug was, indeed, found with a tool called ZeroPath. If not, it's OK, thought I'd ask.
Thank you.
Patch description in my tree now reads:
svcrdma: use
rc_pageofffor memcpy byte offset
svc_rdma_copy_inline_rangeaddedrc_curpage(page index) to the page base instead of the byte offsetrc_pageoff. Userc_pageoffso copies land within the current page.Found by ZeroPath (https://zeropath.com)
Quoted 29 lines · On Friday, 7 November 2025 at 23:09, Chuck Lever [email protected] wrote:
Quoted 28 lines
From: Joshua Rogers [email protected]
svc_rdma_copy_inline_rangeaddedrc_curpage(page index) to the page base instead of the byte offsetrc_pageoff. Userc_pageoffso copies land within the current page.Fixes 8e122582680c ("svcrdma: Move svc_rdma_read_info::ri_pageno to struct svc_rdma_recv_ctxt")X-Cc: [email protected]
Signed-off-by Joshua Rogers [email protected]Signed-off-by Chuck Lever [email protected]---
net/sunrpc/xprtrdma/svc_rdma_rw.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)net/sunrpc/xprtrdma/svc_rdma_rw.c +0
-1@@ -848,7 +848,7 @@ static int svc_rdma_copy_inline_range(struct svc_rqst *rqstp, head->rc_page_count++; dst =page_address (rqstp->rq_pages[head->rc_curpage]); -memcpy (dst + head->rc_curpage, src + offset, page_len);Quoted 8 lines
Quoted 8 lines
net/sunrpc/xprtrdma/svc_rdma_rw.c +1
-0+memcpy ((unsigned char *)dst + head->rc_pageoff, src + offset, page_len);
head->rc_readbytes+=page_len;
head->rc_pageoff+=page_len;--
2.51.0--
Chuck Lever