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)
Thu, Oct 17, 5:43 AM
Unknown Object (File)
Thu, Oct 17, 5:43 AM
Unknown Object (File)
Thu, Oct 17, 5:43 AM
Unknown Object (File)
Thu, Oct 17, 5:22 AM
Unknown Object (File)
Sep 16 2024, 5:26 AM
Unknown Object (File)
Sep 7 2024, 2:21 AM
Unknown Object (File)
Sep 4 2024, 3:54 PM
Unknown Object (File)
Aug 17 2024, 6:43 PM
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().