Page MenuHomeFreeBSD

nfsd: Fix the NFSv4 Readdir operation for an empty ZFS dir
ClosedPublic

Authored by rmacklem on Sep 3 2025, 10:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 9, 11:02 PM
Unknown Object (File)
Thu, Oct 9, 11:02 PM
Unknown Object (File)
Thu, Oct 9, 11:02 PM
Unknown Object (File)
Thu, Oct 9, 7:26 PM
Unknown Object (File)
Fri, Oct 3, 7:57 AM
Unknown Object (File)
Tue, Sep 30, 8:55 AM
Unknown Object (File)
Thu, Sep 25, 1:57 AM
Unknown Object (File)
Wed, Sep 24, 1:18 AM
Subscribers

Details

Summary

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.

Test Plan

Tested for empty directories in both ZFS and UFS
exported file systems to both FreeBSD and Linux
clients. It was the Linux client that found the bug.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable