random st_birthtime

Bruce Evans brde at optusnet.com.au
Fri Mar 21 02:44:49 UTC 2008


On Thu, 20 Mar 2008, Andy Christianson wrote:

> I am running FreeBSD 7.0-RELEASE AMD64 on a dual dual-core xeon system,
> and I am having an odd problem with non-UFS filesystems. Any mounted
> filesystem that is not UFS will return a random, negative st_birthtime.
> Also, each time I stat the file I get a different value.

va_birthtime is used uninitialized for most file systems.

This gives minor security holes -- kernel stack garbage is returned to
userland.  The stack garbage is pointed to in vn_stat() and nothing
changes it for some file systems.

> The two mounted filesystems with this problem are ext2fs and smbfs.

Yes, these are 2 of many which weren't updated when birthtime was
added.

msdosfs is the only file system which initializes unsupported birthtimes
correctly.  It sets va_birthtime.tv_sec to -1, which becomes (time_t)-1,
which is the error value for a time_t though it is often misinterpreted
as 1 second before the Epoch.  Most other file systems are wrong:
- ffs1 sets va_birthtime.tv_sec to the non-error value 0 (the Epoch)
- boot/efi/libefi/efifs.c sets st_birthtime to st_ctime and bzero's
   tv_nsec for all times.  This seems to be correct for st_birthtime
   but wrong for st_ctime, since both are initialized to a creation
   time (fi.info.CreateTime) and no change ime seems to be available.
   msdosfs used to have a similar bug (msdsosfs file systems never have
   ctimes, but the sometimes have creation times; when available, the
   creation time was confused with the change time and converted to
   va_ctime but va_birthtime was not initialized).  ctimes should be
   initialized to mtimes (or better max(all times available)), not
   birthtimes, if no real change times are available.
- zfs, tmpfs, mqfs, shm seem to support birthtimes unconditionally and
   correctly.
- nfsv4 initializes va_birthtime iff the server supports FA4_BTIME for
   the given file.  The FreeBSD nfsv3 server doesn't support FA4_BTIME for
   any file.  The nfsv4 interface is missing the style bug in naming btimes.
   Its names for file times are consistent: [abcm]time where FreeBSD uses
   [acm]time and [acm]time and birthtime.
- no other file system references va_birthtime.

Bruce


More information about the freebsd-bugs mailing list