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)
Fri, Feb 7, 12:28 AM
Unknown Object (File)
Fri, Jan 24, 5:05 PM
Unknown Object (File)
Thu, Jan 23, 6:43 PM
Unknown Object (File)
Sat, Jan 18, 10:18 PM
Unknown Object (File)
Jan 8 2025, 6:45 PM
Unknown Object (File)
Dec 27 2024, 10:14 AM
Unknown Object (File)
Dec 5 2024, 6:22 AM
Unknown Object (File)
Nov 22 2024, 3:19 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().