Page MenuHomeFreeBSD

makefs: Fix 32-bit issues in ZFS time attributes setting
ClosedPublic

Authored by jrtc27 on Aug 11 2022, 12:01 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 25, 8:16 AM
Unknown Object (File)
Thu, Nov 14, 3:04 PM
Unknown Object (File)
Mon, Nov 11, 4:45 PM
Unknown Object (File)
Sun, Nov 10, 12:19 AM
Unknown Object (File)
Fri, Nov 8, 11:30 PM
Unknown Object (File)
Fri, Nov 8, 11:30 PM
Unknown Object (File)
Wed, Nov 6, 1:02 AM
Unknown Object (File)
Wed, Nov 6, 12:50 AM
Subscribers

Details

Summary

Currently the code copies a struct timespec's raw bits as a pair of
uint64_t. On 64-bit systems this has the same representation, but on
32-bit issues there are two issues:

  1. tv_sec is a time_t which is 32-bit on i386 specifically
  2. tv_nsec is a long not a 64-bit integer

On i386, this means the assertion should fire as the size doesn't match.
On other 32-bit systems there are 4 bytes of padding after tv_nsec,
which in practice are probably 0, as this data is ultimately coming from
the kernel, so it's deterministic (though the padding bytes are not
required to be preserved by the compiler, so are strictly unspecified).
However, on 32-bit big-endian systems, the padding bytes are in the
wrong half to be harmless, resulting in the nanoseconds being multiplied
by 2^32.

Fix this all by marshalling via a real uint64_t pair like is done by the
real ZFS_TIME_ENCODE.

Fixes: 240afd8c1fcc ("makefs: Add ZFS support")

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46848
Build 43737: arc lint + arc unit

Event Timeline

Thanks!

Fix this all by marshalling via a real uint64_t pair like is done by the real ZFS_ENCODE_TIME.

What is ZFS_ENCODE_TIME? I can't find that identifier.

This revision is now accepted and ready to land.Aug 11 2022, 12:45 AM

Thanks!

Fix this all by marshalling via a real uint64_t pair like is done by the real ZFS_ENCODE_TIME.

What is ZFS_ENCODE_TIME? I can't find that identifier.

I meant ZFS_TIME_ENCODE...