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
F135349410: D31468.diff
Sun, Nov 9, 12:21 AM
Unknown Object (File)
Thu, Oct 16, 2:25 AM
Unknown Object (File)
Sun, Oct 12, 11:54 PM
Unknown Object (File)
Sun, Oct 12, 10:56 AM
Unknown Object (File)
Sun, Oct 12, 9:05 AM
Unknown Object (File)
Sat, Oct 11, 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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().