Page MenuHomeFreeBSD

vfs: Avoid null dereference
Needs ReviewPublic

Authored by des on Sep 4 2025, 5:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 3, 2:51 AM
Unknown Object (File)
Sat, Sep 27, 1:24 AM
Unknown Object (File)
Thu, Sep 25, 8:41 PM
Unknown Object (File)
Mon, Sep 22, 3:23 PM
Unknown Object (File)
Sun, Sep 21, 3:33 PM
Unknown Object (File)
Sun, Sep 21, 3:23 PM
Unknown Object (File)
Sat, Sep 20, 12:57 PM
Unknown Object (File)
Wed, Sep 17, 4:15 AM
Subscribers

Details

Reviewers
kib
markj
Summary

In VOP_READDIR(), ap->a_eofflag may be null. Check that it isn't
before dereferencing it.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 66821
Build 63704: arc lint + arc unit

Event Timeline

des requested review of this revision.Sep 4 2025, 5:56 PM

Why not fix up the one VOP_READDIR caller which doesn't pass an eof pointer?

Why not fix up the one VOP_READDIR caller which doesn't pass an eof pointer?

Because eofflag is documented to be optional and nullable, there may be third-party code that expects that to be the case, and removing the existing null checks would be more work than adding the handful that were missing.

In D52386#1196301, @des wrote:

Why not fix up the one VOP_READDIR caller which doesn't pass an eof pointer?

Because eofflag is documented to be optional and nullable, there may be third-party code that expects that to be the case, and removing the existing null checks would be more work than adding the handful that were missing.

Where is it documented, in VOP_READDIR.9? Then change the documentation as well.

We do not maintain neither KBI nor KPI compatibility for VFS (or VM), so this change should be even mergeable to stable branches.

In D52386#1196305, @kib wrote:
In D52386#1196301, @des wrote:

Why not fix up the one VOP_READDIR caller which doesn't pass an eof pointer?

Because eofflag is documented to be optional and nullable, there may be third-party code that expects that to be the case, and removing the existing null checks would be more work than adding the handful that were missing.

Where is it documented, in VOP_READDIR.9? Then change the documentation as well.

We do not maintain neither KBI nor KPI compatibility for VFS (or VM), so this change should be even mergeable to stable branches.

I agree, it is better to make the interface simpler even if it's a bit more work. Third-party code can easily adapt to the new semantics.