Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount
@ 2024-01-25 14:42 Jorge Mora
  2024-01-25 17:02 ` Jeff Layton
  2024-01-25 18:03 ` Chuck Lever
  0 siblings, 2 replies; 3+ messages in thread
From: Jorge Mora @ 2024-01-25 14:42 UTC (permalink / raw)
  To: linux-nfs; +Cc: chuck.lever, jlayton

The maxcount is the maximum number of bytes for the LISTXATTRS4resok
result. This includes the cookie and the count for the name array,
thus subtract 12 bytes from the maxcount: 8 (cookie) + 4 (array count)
when filling up the name array.

Fixes: 23e50fe3a5e6 ("nfsd: implement the xattr functions and en/decode logic")
Signed-off-by: Jorge Mora <mora@netapp.com>
---
 fs/nfsd/nfs4xdr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 92c7dde148a4..17e6404f4296 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -5168,7 +5168,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
 	sp = listxattrs->lsxa_buf;
 	nuser = 0;
 
-	xdrleft = listxattrs->lsxa_maxcount;
+	/* Bytes left is maxcount - 8 (cookie) - 4 (array count) */
+	xdrleft = listxattrs->lsxa_maxcount - 12;
 
 	while (left > 0 && xdrleft > 0) {
 		slen = strlen(sp);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount
  2024-01-25 14:42 [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount Jorge Mora
@ 2024-01-25 17:02 ` Jeff Layton
  2024-01-25 18:03 ` Chuck Lever
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2024-01-25 17:02 UTC (permalink / raw)
  To: Jorge Mora, linux-nfs; +Cc: chuck.lever

On Thu, 2024-01-25 at 07:42 -0700, Jorge Mora wrote:
> The maxcount is the maximum number of bytes for the LISTXATTRS4resok
> result. This includes the cookie and the count for the name array,
> thus subtract 12 bytes from the maxcount: 8 (cookie) + 4 (array count)
> when filling up the name array.
> 
> Fixes: 23e50fe3a5e6 ("nfsd: implement the xattr functions and en/decode logic")
> Signed-off-by: Jorge Mora <mora@netapp.com>
> ---
>  fs/nfsd/nfs4xdr.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 92c7dde148a4..17e6404f4296 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -5168,7 +5168,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
>  	sp = listxattrs->lsxa_buf;
>  	nuser = 0;
>  
> -	xdrleft = listxattrs->lsxa_maxcount;
> +	/* Bytes left is maxcount - 8 (cookie) - 4 (array count) */
> +	xdrleft = listxattrs->lsxa_maxcount - 12;
>  
>  	while (left > 0 && xdrleft > 0) {
>  		slen = strlen(sp);

Nice catch!

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount
  2024-01-25 14:42 [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount Jorge Mora
  2024-01-25 17:02 ` Jeff Layton
@ 2024-01-25 18:03 ` Chuck Lever
  1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever @ 2024-01-25 18:03 UTC (permalink / raw)
  To: Jorge Mora; +Cc: linux-nfs, jlayton

On Thu, Jan 25, 2024 at 07:42:23AM -0700, Jorge Mora wrote:
> The maxcount is the maximum number of bytes for the LISTXATTRS4resok
> result. This includes the cookie and the count for the name array,
> thus subtract 12 bytes from the maxcount: 8 (cookie) + 4 (array count)
> when filling up the name array.
> 
> Fixes: 23e50fe3a5e6 ("nfsd: implement the xattr functions and en/decode logic")
> Signed-off-by: Jorge Mora <mora@netapp.com>
> ---
>  fs/nfsd/nfs4xdr.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 92c7dde148a4..17e6404f4296 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -5168,7 +5168,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
>  	sp = listxattrs->lsxa_buf;
>  	nuser = 0;
>  
> -	xdrleft = listxattrs->lsxa_maxcount;
> +	/* Bytes left is maxcount - 8 (cookie) - 4 (array count) */
> +	xdrleft = listxattrs->lsxa_maxcount - 12;
>  
>  	while (left > 0 && xdrleft > 0) {
>  		slen = strlen(sp);
> -- 
> 2.43.0
> 

All four applied to nfsd-next.

Note this checkpatch complaint:

WARNING: From:/Signed-off-by: email address mismatch:
  'From: Jorge Mora <jmora1300@gmail.com>' != 'Signed-off-by: Jorge Mora <mora@netapp.com>'

I'm not sure whether that mismatch is a critical problem. These
look like good fixes and b4 says your DKIM is good, so I applied
them anyway.

-- 
Chuck Lever

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-25 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25 14:42 [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount Jorge Mora
2024-01-25 17:02 ` Jeff Layton
2024-01-25 18:03 ` Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox