Page MenuHomeFreeBSD

makefs: Ensure that FFS superblocks are reproducible
ClosedPublic

Authored by markj on May 6 2025, 3:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jul 5, 10:58 PM
Unknown Object (File)
Sat, Jul 5, 3:22 AM
Unknown Object (File)
Tue, Jul 1, 7:32 AM
Unknown Object (File)
Sun, Jun 29, 2:40 PM
Unknown Object (File)
Wed, Jun 18, 10:37 AM
Unknown Object (File)
May 27 2025, 6:00 AM
Unknown Object (File)
May 26 2025, 4:32 PM
Unknown Object (File)
May 23 2025, 9:40 PM
Subscribers

Details

Summary

The superblock structure has space reserved for a pointer to an
in-memory structure that gets created at mount time. makefs populates
it since that simplifies code elsewhere. However, the pointer value
ends up in the output file, which breaks reproducibility.

Zero the field instead, as its on-disk value is ignored.

Sponsored by: Klara, Inc.
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.May 6 2025, 3:53 PM

Fine with me (even if it does seem a little strange to zero fs_si, copy, and then restore it).
Out of curiosity what do we do in kernel ffs?

This revision is now accepted and ready to land.May 6 2025, 4:44 PM

Fine with me (even if it does seem a little strange to zero fs_si, copy, and then restore it).

At first I tried not populating it at all, but that introduces a bunch of complexity elsewhere.

Out of curiosity what do we do in kernel ffs?

The on-disk value seems to be ignored. ffs_sbget() allocates the summary info structure and glues it into the returned superblock structure, overwriting whatever happened to be on disk.

This has been fixed in newfs for some time. Along with numerous other changes like checkhash validations, superblock integrity checks, and other fixes and improvements. In my opinion makefs/ffs should just use use newfs/mkfs.c rather than (poorly) trying to parody it.