Page MenuHomeFreeBSD

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

Authored by rmacklem on Mon, Jan 12, 11:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jan 13, 4:00 PM
Unknown Object (File)
Tue, Jan 13, 3:59 PM
Unknown Object (File)
Tue, Jan 13, 12:51 PM
Subscribers

Details

Reviewers
markj
emaste
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.Thu, Jan 15, 12:38 AM