Date: Thu, 8 May 2025 16:03:55 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 764ccf410c3c - main - makefs: Ensure that FFS superblocks are reproducible Message-ID: <202505081603.548G3t6u073353@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=764ccf410c3c5453c4656113d75cd81fcf01828d commit 764ccf410c3c5453c4656113d75cd81fcf01828d Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-05-08 15:49:53 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-05-08 15:49:53 +0000 makefs: Ensure that FFS superblocks are reproducible 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 when writing the superblock instead, as its on-disk value is ignored. Reviewed by: emaste MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50196 --- usr.sbin/makefs/ffs/mkfs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c index b2f752102a69..81e3da5725c8 100644 --- a/usr.sbin/makefs/ffs/mkfs.c +++ b/usr.sbin/makefs/ffs/mkfs.c @@ -579,13 +579,21 @@ ffs_write_superblock(struct fs *fs, const fsinfo_t *fsopts) { int size, blks, i, saveflag; uint32_t cylno; - void *space; + void *info, *space; char *wrbuf; saveflag = fs->fs_flags & FS_INTERNAL; fs->fs_flags &= ~FS_INTERNAL; - memcpy(writebuf, &sblock, sbsize); + /* + * Write out the superblock. Blank out the summary info field, as it's + * a random pointer that would make the resulting image unreproducible. + */ + info = fs->fs_si; + fs->fs_si = NULL; + memcpy(writebuf, fs, sbsize); + fs->fs_si = info; + if (fsopts->needswap) ffs_sb_swap(fs, (struct fs*)writebuf); ffs_wtfs(fs->fs_sblockloc / sectorsize, sbsize, writebuf, fsopts);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505081603.548G3t6u073353>