From nobody Thu Aug 18 01:46:42 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M7SRQ3pz9z4YvMX; Thu, 18 Aug 2022 01:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M7SRQ3GXTz3lRx; Thu, 18 Aug 2022 01:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660787202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AcMYnVFmo/5IPh05JC6VN5JYmPpVfCo28BA26QuWTLg=; b=qY6UQ+M3MomHxrjjMOdiLgkthYl2vFxCwItgAkgLouTikZiCzXtkARgRUbGUsBEhhJ5VVT yzQ6PuBWq4hFEBYrjR27JJ5VMO3U5/LwoTCqXcRAOliWtqiU1ZbR4SnSHehNo2jnW3pyVh SNUGI6VsWtRebDzETyzXOOcIo5hIiQokT1SD6dLRfMKBlBfnva8EbncNK+0WtMtPXhhwUT HJ/IuvlJ1D1bisCFEGpfl0AIu44XsZLc95Vbx1te0OakhhEfd+olLLqvxPl43mFjNORL0R XzUJuqcEOSWevz3WmBXfGfsx4YxRWzqbY0pzl6CE9EqsPvFOVwNf74DOSPLTJg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M7SRQ2JZmz19wx; Thu, 18 Aug 2022 01:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27I1kgUi095016; Thu, 18 Aug 2022 01:46:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27I1kg5P095015; Thu, 18 Aug 2022 01:46:42 GMT (envelope-from git) Date: Thu, 18 Aug 2022 01:46:42 GMT Message-Id: <202208180146.27I1kg5P095015@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: b0ce7dfc5e28 - main - makefs: Fix 32-bit issues in ZFS time attributes setting List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b0ce7dfc5e28650980d52f45aadd79e10012c291 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660787202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AcMYnVFmo/5IPh05JC6VN5JYmPpVfCo28BA26QuWTLg=; b=kblSnjNXLiUu555D1nEiZ8nsJhHS12Y1tFOgl9PRc8YBrDeqe5EsYTkSJex+/rwtmBiYF8 d6a0zjQv6tTVq7wpa/IvrNZOAC52ddykncDND8X3+8yYqEHbbRvmXCWGCcHJrOeg4CM7N1 UYPUCdbk6MNiLuyA3Uwqil/4+18/KAwGvx+M4cUIeVn7R9fXfGT6j4ppZu6C1QyRktloD5 n/nzrhUpLaP9G7Y/qKlzoIpFuBSVLlhXKzZMka2UrjIL/4rO7Iget/FeyMfF3WE1CPOqlV MugFjAv5JqmIRERgcAe9aWtXeYVGYJYdX97VI2QnP3yQJIlIU5vW7A/gq2ge0A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660787202; a=rsa-sha256; cv=none; b=GmJnx1Uv/T8UBHrncWsoHfR2Jxw2nI5z8UP0PnY9dvys52kW+2OyiyN6h/vuwDcdrgujld gitJEBS1RANpYhnP7n0fpUvqiHfaB5LNpReuyyczEusXcwpKI05gNA1kvmjnuHgsjZbfv+ 2PgVwrJYJreL+wbJXAB5foaiIa9hDoAJArd8ChKfg0+c70GDXyiH7wuXuBGSCteQhu03o+ FfBYj6RbtjWH0HjKFUHhrk+V+GJAAgdWs9RMZ/csh1hKgtq1XxDuhgKfiX1XTv6wKTvtkP fClnE1ETayYQcx5oJZKG8ejBC/o50Fmc5A7fYlLHkFGebj51PncpGWEEvh1Kvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=b0ce7dfc5e28650980d52f45aadd79e10012c291 commit b0ce7dfc5e28650980d52f45aadd79e10012c291 Author: Jessica Clarke AuthorDate: 2022-08-18 01:46:27 +0000 Commit: Jessica Clarke CommitDate: 2022-08-18 01:46:27 +0000 makefs: Fix 32-bit issues in ZFS time attributes setting 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. Reviewed by: markj Fixes: 240afd8c1fcc ("makefs: Add ZFS support") Differential Revision: https://reviews.freebsd.org/D36131 --- usr.sbin/makefs/zfs/fs.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/usr.sbin/makefs/zfs/fs.c b/usr.sbin/makefs/zfs/fs.c index b246a8e23f4e..bf8d5483d610 100644 --- a/usr.sbin/makefs/zfs/fs.c +++ b/usr.sbin/makefs/zfs/fs.c @@ -301,6 +301,21 @@ fs_readlink(const fsnode *cur, struct fs_populate_arg *arg, buf[n] = '\0'; } +static void +fs_populate_time(zfs_fs_t *fs, char *attrbuf, struct timespec *ts, + uint16_t ind, size_t *szp) +{ + uint64_t timebuf[2]; + + assert(ind < fs->sacnt); + assert(fs->saoffs[ind] != 0xffff); + assert(fs->satab[ind].size == sizeof(timebuf)); + + timebuf[0] = ts->tv_sec; + timebuf[1] = ts->tv_nsec; + fs_populate_attr(fs, attrbuf, timebuf, ind, szp); +} + static void fs_populate_sattrs(struct fs_populate_arg *arg, const fsnode *cur, dnode_phys_t *dnode) @@ -438,14 +453,10 @@ fs_populate_sattrs(struct fs_populate_arg *arg, const fsnode *cur, * We deliberately set atime = mtime here to ensure that images are * reproducible. */ - assert(sizeof(sb->st_mtim) == fs->satab[ZPL_ATIME].size); - fs_populate_attr(fs, attrbuf, &sb->st_mtim, ZPL_ATIME, &bonussz); - assert(sizeof(sb->st_ctim) == fs->satab[ZPL_CTIME].size); - fs_populate_attr(fs, attrbuf, &sb->st_ctim, ZPL_CTIME, &bonussz); - assert(sizeof(sb->st_mtim) == fs->satab[ZPL_MTIME].size); - fs_populate_attr(fs, attrbuf, &sb->st_mtim, ZPL_MTIME, &bonussz); - assert(sizeof(sb->st_birthtim) == fs->satab[ZPL_CRTIME].size); - fs_populate_attr(fs, attrbuf, &sb->st_birthtim, ZPL_CRTIME, &bonussz); + fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_ATIME, &bonussz); + fs_populate_time(fs, attrbuf, &sb->st_ctim, ZPL_CTIME, &bonussz); + fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_MTIME, &bonussz); + fs_populate_time(fs, attrbuf, &sb->st_birthtim, ZPL_CRTIME, &bonussz); fs_populate_varszattr(fs, attrbuf, aces, sizeof(aces), 0, ZPL_DACL_ACES, &bonussz);