[PATCH] SUNRPC: fix oversized GSS proxy token copy

Jérémy Jean posted 1 patch 2 weeks, 1 day ago
net/sunrpc/auth_gss/svcauth_gss.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
[PATCH] SUNRPC: fix oversized GSS proxy token copy
Posted by Jérémy Jean 2 weeks, 1 day ago
gss_read_proxy_verf() allocates one page per token chunk, but it copies the
entire linear head of an RPC request into in_token->pages[0]. A UDP datagram
can leave more than PAGE_SIZE bytes in the linear head, so a large
RPCSEC_GSS INIT token overwrites following pages.

Copy the linear head in page-sized chunks before switching to the request
page array. The linear head itself can span multiple pages.

Fixes: 5866efa8cbfb ("SUNRPC: Fix svcauth_gss_proxy_init()")
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Assisted-by: Codex:gpt-5
---
 net/sunrpc/auth_gss/svcauth_gss.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 967e9d5..ad1e178 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -1085,10 +1085,11 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
 	}
 
 	length = min_t(unsigned int, inlen, (char *)xdr->end - (char *)xdr->p);
-	if (length)
-		memcpy(page_address(in_token->pages[0]), xdr->p, length);
+	for (to_offs = 0; to_offs < length; to_offs += PAGE_SIZE)
+		memcpy(page_address(in_token->pages[to_offs >> PAGE_SHIFT]),
+		       (char *)xdr->p + to_offs,
+		       min_t(unsigned int, length - to_offs, PAGE_SIZE));
 	inlen -= length;
-
 	to_offs = length;
 	from_offs = rqstp->rq_arg.page_base;
 	while (inlen) {
-- 
2.47.3

Re: [PATCH] SUNRPC: fix oversized GSS proxy token copy
Posted by Chuck Lever 2 weeks ago
On Thu, 10 Sep 2026 12:51:20 +0000, Jérémy Jean wrote:
> gss_read_proxy_verf() allocates one page per token chunk, but it copies the
> entire linear head of an RPC request into in_token->pages[0]. A UDP datagram
> can leave more than PAGE_SIZE bytes in the linear head, so a large
> RPCSEC_GSS INIT token overwrites following pages.
> 
> Copy the linear head in page-sized chunks before switching to the request
> page array. The linear head itself can span multiple pages.
> 
> [...]

Applied to nfsd-testing, thanks!

[1/1] SUNRPC: fix oversized GSS proxy token copy
      commit: c01472559c0e38174c89d86adc698cae0551cae6

--
Chuck Lever