summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldo Ariel Panzardo <qwe.aldo@gmail.com>2026-09-15 14:39:01 -0300
committerChuck Lever <cel@kernel.org>2026-10-11 23:12:04 -0400
commitfdce4109ec2220fedb42bc22967656e03fe4e9fe (patch)
treed3241f8a8a6cc1f545125fd2e08369569b09d5f2
parentfcc202d324e5d2a21557ddd20fc3f96e08c4f72d (diff)
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 <jlayton@kernel.org> Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com> [ cel: Rewrote commit message ] Reviewed-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20260915173902.3184534-1-qwe.aldo@gmail.com Signed-off-by: Chuck Lever <cel@kernel.org>
-rw-r--r--fs/nfsd/nfs4xdr.c12
1 files 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;