From fdce4109ec2220fedb42bc22967656e03fe4e9fe Mon Sep 17 00:00:00 2001 From: Aldo Ariel Panzardo Date: Tue, 15 Sep 2026 14:39:01 -0300 Subject: [PATCH] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments nfsd4_vbuf_to_stream() encodes the first fragment and a short final fragment with xdr_encode_opaque_fixed(), but copies each full-page fragment in the loop with a bare memcpy(). A PAGE_SIZE fragment is a whole number of XDR words, so the memcpy() leaves no padding unwritten; the two code paths differ in form, not in result. Encode every fragment with xdr_encode_opaque_fixed(). The short-fragment branch then reduces to the loop exit, and the padding comment it carried goes with it. Suggested-by: Jeff Layton Signed-off-by: Aldo Ariel Panzardo [ cel: Rewrote commit message ] Reviewed-by: Jeff Layton Link: https://patch.msgid.link/20260915173902.3184534-1-qwe.aldo@gmail.com Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index aec98dc4e52b..84161dbecd1c 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -6368,17 +6368,9 @@ nfsd4_vbuf_to_stream(struct xdr_stream *xdr, char *buf, u32 buflen) if (!p) return nfserr_resource; - memcpy(p, buf, cplen); - - if (cplen < PAGE_SIZE) { - /* - * We're done, with a length that wasn't page - * aligned, so possibly not word aligned. Pad - * any trailing bytes with 0. - */ - xdr_encode_opaque_fixed(p, NULL, cplen); + xdr_encode_opaque_fixed(p, buf, cplen); + if (cplen < PAGE_SIZE) break; - } buflen -= PAGE_SIZE; buf += PAGE_SIZE;