Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Sep 2025 01:51:52 GMT
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 1c52d525f064 - main - nfsd: Fix the NFSv4 Readdir operation for an empty ZFS dir
Message-ID:  <202509040151.5841pqCo084930@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=1c52d525f06411726d7755081f904de64749eb9b

commit 1c52d525f06411726d7755081f904de64749eb9b
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2025-09-04 01:48:52 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2025-09-04 01:48:52 +0000

    nfsd: Fix the NFSv4 Readdir operation for an empty ZFS dir
    
    Commit 9a3edc8 modified the behaviour of ZFS's
    VOP_READDIR() such that it will reply EINVAL for
    an offset past EOF on the directory.
    
    This exposed a latent bug in the NFSv4 Readdir
    code, which would attempt a Readdir with an
    offset beyond EOF for a directory that consists
    of only "." and "..". This happened because NFSv4
    does not reply "." or ".." to the client and, after
    skipping over them, attempted another VOP_READDIR().
    
    This patch fixes the problem by checking the eofflag
    for the case where all entries have been skipped over.
    
    Reviewed by:    kib
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D52370
---
 sys/fs/nfsserver/nfs_nfsdport.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index b2966934f9b7..7040c4afb797 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -2607,6 +2607,7 @@ again:
 	 * rpc reply
 	 */
 	if (siz == 0) {
+ateof:
 		vput(vp);
 		if (nd->nd_flag & ND_NFSV3)
 			nfsrv_postopattr(nd, getret, &at);
@@ -2648,6 +2649,8 @@ again:
 		ncookies--;
 	}
 	if (cpos >= cend || ncookies == 0) {
+		if (eofflag != 0)
+			goto ateof;
 		siz = fullsiz;
 		toff = off;
 		goto again;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509040151.5841pqCo084930>