linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever III <chuck.lever@oracle.com>
To: "trondmy@kernel.org" <trondmy@kernel.org>
Cc: Bruce Fields <bfields@redhat.com>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero
Date: Fri, 1 Oct 2021 15:59:36 +0000	[thread overview]
Message-ID: <C079F240-64D2-4967-BCD2-4A6C425A78DA@oracle.com> (raw)
In-Reply-To: <20210930194442.249907-1-trondmy@kernel.org>



> On Sep 30, 2021, at 3:44 PM, trondmy@kernel.org wrote:
> 
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> RFC3530 notes that the 'dircount' field may be zero, in which case the
> recommendation is to ignore it, and only enforce the 'maxcount' field.
> In RFC5661, this recommendation to ignore a zero valued field becomes a
> requirement.
> 
> Fixes: aee377644146 ("nfsd4: fix rd_dircount enforcement")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Pulled into the next 5.15-rc for NFSD. Thanks!


> ---
> fs/nfsd/nfs4xdr.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 7abeccb975b2..cf030ebe2827 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3544,15 +3544,18 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
> 		goto fail;
> 	cd->rd_maxcount -= entry_bytes;
> 	/*
> -	 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", so
> -	 * let's always let through the first entry, at least:
> +	 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", and
> +	 * notes that it could be zero. If it is zero, then the server
> +	 * should enforce only the rd_maxcount value.
> 	 */
> -	if (!cd->rd_dircount)
> -		goto fail;
> -	name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
> -	if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
> -		goto fail;
> -	cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
> +	if (cd->rd_dircount) {
> +		name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
> +		if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
> +			goto fail;
> +		cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
> +		if (!cd->rd_dircount)
> +			cd->rd_maxcount = 0;
> +	}
> 
> 	cd->cookie_offset = cookie_offset;
> skip_entry:
> -- 
> 2.31.1
> 

--
Chuck Lever




      parent reply	other threads:[~2021-10-01 15:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30 19:44 [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero trondmy
2021-09-30 19:44 ` [PATCH 2/2] nfsd: Fix a warning for nfsd_file_close_inode trondmy
2021-10-01 15:59 ` Chuck Lever III [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=C079F240-64D2-4967-BCD2-4A6C425A78DA@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@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;
as well as URLs for NNTP newsgroup(s).