aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2025-09-04 01:48:52 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2025-09-04 01:48:52 +0000
commit1c52d525f06411726d7755081f904de64749eb9b (patch)
tree70037a11d40ba32da75dfc0b5f051b06275859f8
parentb5c46895fdddcdb7dd1994598925d6989ea7c8f2 (diff)
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
-rw-r--r--sys/fs/nfsserver/nfs_nfsdport.c3
1 files changed, 3 insertions, 0 deletions
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;