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)
Wed, Mar 4, 6:16 AM
Unknown Object (File)
Mon, Mar 2, 8:27 PM
Unknown Object (File)
Mon, Mar 2, 8:27 PM
Unknown Object (File)
Mon, Feb 23, 8:18 PM
Unknown Object (File)
Mon, Feb 23, 2:15 AM
Unknown Object (File)
Sun, Feb 8, 5:14 AM
Unknown Object (File)
Sat, Feb 7, 7:14 PM
Unknown Object (File)
Jan 31 2026, 5:05 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().