Page MenuHomeFreeBSD

linux_file.c: Fix handling of NFS getdents() emulation
ClosedPublic

Authored by rmacklem on Jan 12 2026, 11:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 14, 2:21 PM
Unknown Object (File)
Sat, Feb 14, 9:18 AM
Unknown Object (File)
Sun, Feb 8, 6:35 AM
Unknown Object (File)
Jan 25 2026, 4:00 PM
Unknown Object (File)
Jan 25 2026, 12:37 PM
Unknown Object (File)
Jan 25 2026, 12:16 AM
Unknown Object (File)
Jan 23 2026, 1:00 AM
Unknown Object (File)
Jan 21 2026, 2:06 PM
Subscribers

Details

Summary

Bugzilla PR#292282 reports a problem, where a Linux
binary running in the Linuxulator gets bogus entries
in a readdir()/getdents() reply when the directory is
an NFS mount.

This appears to be caused by the NFS client including
entries with d_fileno == 0, which are always ignored by
BSD, but are not ignored by Linux.

This patch filters out the "d_fileno == 0" entries and
the reporter of the bugzilla PR notes that it fixes the
problem for him.

It could be argued that the NFS client should filter out
the "d_fileno == 0" entries, but the NFS client readdir
code is "fragile" and any change to it runs a significant
risk of causing regression type problems.

As such, since the LInuxulator is already broken for this
case, it seems safer to filter them out there.

I do not currently have a way to test this patch, but the
bugzilla reporter has tested it and confirmed it fixed the
problem for them.

(If there is someone else taking care of the Linuxulator,
please add them to the review.)

Test Plan

Tested by the bugzilla reporter.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Looks ok to me aside from the comment.

sys/compat/linux/linux_file.c
455–456

There's a corner case here which probably doesn't matter, but, if args->count is close to UINT_MAX, rounding up here will convert it to zero. It looks more natural to me to round up after computing the min.

534–535

Same comment here.

Do roundup2() after the min(args->count, MAXBSIZE)
as suggsted by markj@.

This revision is now accepted and ready to land.Jan 15 2026, 12:38 AM