Page MenuHomeFreeBSD

vfs: Avoid a comparison with an uninitialized field in setutimes()
ClosedPublic

Authored by markj on Aug 8 2021, 9:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 9, 12:21 AM
Unknown Object (File)
Thu, Oct 16, 2:25 AM
Unknown Object (File)
Oct 12 2025, 11:54 PM
Unknown Object (File)
Oct 12 2025, 10:56 AM
Unknown Object (File)
Oct 12 2025, 9:05 AM
Unknown Object (File)
Oct 11 2025, 9:35 PM
Unknown Object (File)
Sep 21 2025, 1:14 AM
Unknown Object (File)
Sep 14 2025, 6:22 AM
Subscribers

Details

Summary

Some filesystems, e.g., devfs, do not populate va_birthtime in their
GETATTR implementations. To handle this, make sure that va_birthtime is
initialized to the quasi-standard value of { VNOVAL, 0 } before calling
VOP_GETATTR.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 40931
Build 37820: arc lint + arc unit

Event Timeline

markj requested review of this revision.Aug 8 2021, 9:53 PM

I am fine with this, but also wonder if it makes sense to fill birthtime for devfs. We can record the make_dev() time in cdev_priv inside devfs_alloc()

This revision is now accepted and ready to land.Aug 8 2021, 10:24 PM

To be clear, this change is mimicking vop_stdstat(), which pre-initializes several fields explicitly.

In D31468#709284, @kib wrote:

I am fine with this, but also wonder if it makes sense to fill birthtime for devfs. We can record the make_dev() time in cdev_priv inside devfs_alloc()

I can't see any problem with that, but I am not sure whether it would be useful to anyone vs. simply initializing va_birthtime to {-1, 0} in devfs_getattr().