Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 May 2023 16:19:33 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 271174] NFS readdir truncates dirent fileid to 32 bits
Message-ID:  <bug-271174-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271174

            Bug ID: 271174
           Summary: NFS readdir truncates dirent fileid to 32 bits
           Product: Base System
           Version: 12.4-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: bmueller@panasas.com

The return result of an NFS readdir rpc include directory entries (dirents)=
.=20
According to NFSv3 RFC, the struct entry3 (which represent the dirents)
contains type fileid3 for the fileid.  fileid3 is a 64 bit number.

However, we can see that in the FreeBSD kernel NFS server, when assembling =
the
dirent, the server only marshalls 32 bits of the d_fileno:
https://github.com/freebsd/freebsd-src/blob/main/sys/fs/nfsserver/nfs_nfsdp=
ort.c#L2259.
 This results in the lower 32 bits of the fileno being transmitted.

This manifests as a problem with the libc getcwd call because under some
circumstances, getcwd wants to manually determine the cwd by doing a series=
 of
readdirs, comparing the inode number (fileid) from the direntries with a st=
at
of the current directory.  Stat (NFS getattr) will return a 64 bit fileid, =
but
the readdir will be 32 bits, so the comparison never matches and getcwd fai=
ls.

The NFS server can be fixed by doing 64 bit fileid marshalling for NFSv3/4,
while leaving it as 32 bits for NFSv2 where fileid.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



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