From: Yiran Qiu <eritque-arcus@ikuyo.dev>
To: cel@kernel.org, jlayton@kernel.org
Cc: neil@brown.name, okorniev@redhat.com, Dai.Ngo@oracle.com,
tom@talpey.com, linux-nfs@vger.kernel.org,
linux-kernel@vger.kernel.org, Yiran Qiu <eritque-arcus@ikuyo.dev>,
stable@vger.kernel.org
Subject: [PATCH] SUNRPC: copy the GSS init token with read_bytes_from_xdr_buf()
Date: Fri, 20 Nov 2026 01:00:07 -0500 [thread overview]
Message-ID: <20261120060007.302599-1-eritque-arcus@ikuyo.dev> (raw)
gss_read_proxy_verf() copies the token from the head of rq_arg and then
from rq_arg.pages, assuming the rest of the token is in the page list.
svcrdma rebuilds a Call that carries one Read chunk as head (inline data
before the chunk position), pages (the chunk) and tail (inline data
after it), and xdr_stream_remaining() counts the tail. When the token
starts at the chunk and continues into the tail, the copy runs past the
chunk's pages. If the chunk fills rq_pages, the copy takes the NULL
entry at rq_pages[rq_maxpages] and memcpy() reads from
page_address(NULL); otherwise the stale contents of the next page go to
gssproxy in place of the tail. This runs in svcauth_gss_proxy_init()
before any credential is checked, so a client of an NFS/RDMA server that
uses gssproxy can oops nfsd threads without authenticating.
Commit 62319c2534b6 ("SUNRPC: fix oversized GSS proxy token copy") fixed
the copy from the head and left the copy from the pages as it was. Copy
the token with read_bytes_from_xdr_buf(), which follows head, pages and
tail.
Found with afb-afl, an LLM-driven kernel audit/repro pipeline; the fix
and this changelog were also drafted with LLM assistance. Reproduced on
an unmodified KASAN build of mainline, nfsd listening on "rdma 20049"
over rxe with use-gss-proxy set. An RPCSEC_GSS INIT Call whose token is
a 12-page Read chunk (max_block_size 32768) plus 64 inline bytes gives
(gss_read_proxy_verf() is inlined):
BUG: KASAN: wild-memory-access in svcauth_gss_proxy_init+0x71f/0xe10
Read of size 64 at addr 0005088000000000 by task nfsd/184
__asan_memcpy+0x23/0x60
svcauth_gss_proxy_init+0x71f/0xe10
svcauth_gss_proc_init+0x22b/0x440
With an 11-page chunk, gssproxy received the chunk followed by 64 bytes
that were not the tail. With this patch there is no report and gssproxy
receives the chunk followed by the tail, for 12- and 11-page chunks; a
chunk without a tail and an inline token are unchanged. Over TCP, tokens
of 100 to 30000 bytes reach gssproxy intact with and without this patch.
Kerberos and NFS functional tests were not run.
Fixes: 5866efa8cbfb ("SUNRPC: Fix svcauth_gss_proxy_init()")
Cc: stable@vger.kernel.org
Signed-off-by: Yiran Qiu <eritque-arcus@ikuyo.dev>
---
Tested on mainline 4405c18c95d2 (v7.4-rc3+) in QEMU. Applies to
cel/linux.git nfsd-next and nfsd-testing.
A reproducer and the test logs are available on request.
net/sunrpc/auth_gss/svcauth_gss.c | 38 +++++++++----------------------
1 file changed, 11 insertions(+), 27 deletions(-)
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 43839e805531..da4043aed247 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -1056,9 +1056,8 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
struct gssp_in_token *in_token)
{
struct xdr_stream *xdr = &rqstp->rq_arg_stream;
- unsigned int length, pgto_offs, pgfrom_offs;
- int pages, i, pgto, pgfrom;
- size_t to_offs, from_offs;
+ unsigned int base, length;
+ int pages, i;
u32 inlen;
if (dup_netobj(in_handle, &gc->gc_ctx))
@@ -1090,30 +1089,15 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
}
}
- length = min_t(unsigned int, inlen, (char *)xdr->end - (char *)xdr->p);
- 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) {
- pgto = to_offs >> PAGE_SHIFT;
- pgfrom = from_offs >> PAGE_SHIFT;
- pgto_offs = to_offs & ~PAGE_MASK;
- pgfrom_offs = from_offs & ~PAGE_MASK;
-
- length = min_t(unsigned int, inlen,
- min_t(unsigned int, PAGE_SIZE - pgto_offs,
- PAGE_SIZE - pgfrom_offs));
- memcpy(page_address(in_token->pages[pgto]) + pgto_offs,
- page_address(rqstp->rq_arg.pages[pgfrom]) + pgfrom_offs,
- length);
-
- to_offs += length;
- from_offs += length;
- inlen -= length;
+ base = xdr_stream_pos(xdr);
+ for (i = 0; i < pages; i++) {
+ length = min_t(unsigned int, inlen - i * PAGE_SIZE, PAGE_SIZE);
+ if (read_bytes_from_xdr_buf(&rqstp->rq_arg, base + i * PAGE_SIZE,
+ page_address(in_token->pages[i]),
+ length)) {
+ gss_free_in_token_pages(in_token);
+ goto out_denied_free;
+ }
}
return 0;
--
2.56.1
reply other threads:[~2026-11-20 6:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261120060007.302599-1-eritque-arcus@ikuyo.dev \
--to=eritque-arcus@ikuyo.dev \
--cc=Dai.Ngo@oracle.com \
--cc=cel@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®