* [PATCH] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments
@ 2026-09-15 17:39 Aldo Ariel Panzardo
2026-09-15 19:08 ` Chuck Lever
2026-09-15 19:23 ` Jeff Layton
0 siblings, 2 replies; 3+ messages in thread
From: Aldo Ariel Panzardo @ 2026-09-15 17:39 UTC (permalink / raw)
To: Chuck Lever, Jeff Layton
Cc: linux-nfs, linux-kernel, stable, Aldo Ariel Panzardo
nfsd4_vbuf_to_stream() already uses xdr_encode_opaque_fixed() when the
final fragment is shorter than a page, but the preceding memcpy() in the
loop body does not clear XDR padding.
When the last fragment happens to be exactly PAGE_SIZE the short-fragment
branch is never entered, and the loop exits through the normal buflen
path. If that final page-sized reservation is not word-aligned within
the XDR stream, its padding bytes are left stale.
Convert the loop memcpy to xdr_encode_opaque_fixed() and drop the now
redundant short-fragment padding block, matching the first-fragment fix.
Suggested-by: Jeff Layton <jlayton@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
---
fs/nfsd/nfs4xdr.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -5963,15 +5963,7 @@ 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);
- break;
- }
+ xdr_encode_opaque_fixed(p, buf, cplen);
+ if (cplen < PAGE_SIZE)
+ break;
buflen -= PAGE_SIZE;
buf += PAGE_SIZE;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments
2026-09-15 17:39 [PATCH] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments Aldo Ariel Panzardo
@ 2026-09-15 19:08 ` Chuck Lever
2026-09-15 19:23 ` Jeff Layton
1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever @ 2026-09-15 19:08 UTC (permalink / raw)
To: Jeff Layton, Chuck Lever, Aldo Ariel Panzardo
Cc: linux-nfs, linux-kernel, stable
On Tue, 15 Sep 2026 14:39:01 -0300, Aldo Ariel Panzardo wrote:
> nfsd4_vbuf_to_stream() already uses xdr_encode_opaque_fixed() when the
> final fragment is shorter than a page, but the preceding memcpy() in the
> loop body does not clear XDR padding.
>
> When the last fragment happens to be exactly PAGE_SIZE the short-fragment
> branch is never entered, and the loop exits through the normal buflen
> path. If that final page-sized reservation is not word-aligned within
> the XDR stream, its padding bytes are left stale.
>
> [...]
Applied to nfsd-testing, thanks!
[1/1] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments
commit: 802e78a4db687ee132ae9c71992490c201fdc39e
--
Chuck Lever
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments
2026-09-15 17:39 [PATCH] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments Aldo Ariel Panzardo
2026-09-15 19:08 ` Chuck Lever
@ 2026-09-15 19:23 ` Jeff Layton
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2026-09-15 19:23 UTC (permalink / raw)
To: Aldo Ariel Panzardo, Chuck Lever; +Cc: linux-nfs, linux-kernel, stable
On Tue, 2026-09-15 at 14:39 -0300, Aldo Ariel Panzardo wrote:
> nfsd4_vbuf_to_stream() already uses xdr_encode_opaque_fixed() when the
> final fragment is shorter than a page, but the preceding memcpy() in the
> loop body does not clear XDR padding.
>
> When the last fragment happens to be exactly PAGE_SIZE the short-fragment
> branch is never entered, and the loop exits through the normal buflen
> path. If that final page-sized reservation is not word-aligned within
> the XDR stream, its padding bytes are left stale.
>
> Convert the loop memcpy to xdr_encode_opaque_fixed() and drop the now
> redundant short-fragment padding block, matching the first-fragment fix.
>
> Suggested-by: Jeff Layton <jlayton@kernel.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
> ---
> fs/nfsd/nfs4xdr.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index XXXXXXX..XXXXXXX 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -5963,15 +5963,7 @@ 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);
> - break;
> - }
> + xdr_encode_opaque_fixed(p, buf, cplen);
> + if (cplen < PAGE_SIZE)
> + break;
>
> buflen -= PAGE_SIZE;
> buf += PAGE_SIZE;
>
> --
> 2.43.0
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-15 19:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 17:39 [PATCH] nfsd: use xdr_encode_opaque_fixed for all GETXATTR fragments Aldo Ariel Panzardo
2026-09-15 19:08 ` Chuck Lever
2026-09-15 19:23 ` Jeff Layton
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®