Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Jorge Mora <jmora1300@gmail.com>, linux-nfs@vger.kernel.org
Cc: chuck.lever@oracle.com
Subject: Re: [PATCH] NFSD: fix LISTXATTRS returning a short list with eof=TRUE
Date: Thu, 25 Jan 2024 12:03:13 -0500	[thread overview]
Message-ID: <308370cb5db78f580bbad88e9752f9b0c8b17aef.camel@kernel.org> (raw)
In-Reply-To: <20240125144528.12763-1-mora@netapp.com>

On Thu, 2024-01-25 at 07:45 -0700, Jorge Mora wrote:
> If the XDR buffer is not large enough to fit all attributes
> and the remaining bytes left in the XDR buffer (xdrleft) is
> equal to the number of bytes for the current attribute, then
> the loop will prematurely exit without setting eof to FALSE.
> Also in this case, adding the eof flag to the buffer will
> make the reply 4 bytes larger than lsxa_maxcount.
> 
> Need to check if there are enough bytes to fit not only the
> next attribute name but also the eof as well.
> 
> 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 17e6404f4296..26993bf368fc 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -5182,7 +5182,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
>  
>  		slen -= XATTR_USER_PREFIX_LEN;
>  		xdrlen = 4 + ((slen + 3) & ~3);
> -		if (xdrlen > xdrleft) {
> +		/* Check if both entry and eof can fit in the XDR buffer */
> +		if (xdrlen + 4 > xdrleft) {
>  			if (count == 0) {
>  				/*
>  				 * Can't even fit the first attribute name.

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

      reply	other threads:[~2024-01-25 17:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 14:45 [PATCH] NFSD: fix LISTXATTRS returning a short list with eof=TRUE Jorge Mora
2024-01-25 17:03 ` Jeff Layton [this message]

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=308370cb5db78f580bbad88e9752f9b0c8b17aef.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jmora1300@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    /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