From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id F34672A47; Tue, 25 Nov 2025 12:32:22 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id B30832A39; Tue, 25 Nov 2025 12:32:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) by atuin.qyliss.net (Postfix) with ESMTPS id D9CC02A37 for ; Tue, 25 Nov 2025 12:32:19 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 308101400188; Tue, 25 Nov 2025 07:32:18 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 25 Nov 2025 07:32:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1764073938; x=1764160338; bh=MZy6T8/LAo dT6Bw5Vl/dESacV8tIqYOdg94h4RaTRos=; b=IbSPzjs+KoHq5qjYFupkwXoIkI ATX1mx68Rc+X770uVaraOXsoS6yZhNCjrlzq3CA4WwI77lissa1XoTY4iClSBZIk NOXcZKsNl0pPAUqNoT80MHmRgHty6jP2HkHeuzqgrGakm5RhEDxDOZHwK7E6W+kk /A2GuyQU0laCNOWM+DyIYm2DswHHdkyV4+Kz/veGZlNkrhGsUq63OID2kHQJs2YD lzmm8DQiCm4YlQX/YKOZgAICUXYRHPDJrJ8Bz58wFVm31tDjAxX3gh0tOywP1f0h JX6+rBOEf0IvWnuiKhOWDYlcGYTAvMJm9X8Gg3t6x8V6t2LSIY/G5Iva3t/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1764073938; x=1764160338; bh=MZy6T8/LAodT6Bw5Vl/dESacV8tIqYOdg94 h4RaTRos=; b=aYeX9YOfmqaAeKzi8m1SIJWi1MkpN0N5lNiqDUqSXXQyBxkO/Wf o+kqdUyPNU/9TwHayz77T1zrYGQs77YuOrjs+S8S5TZNIvY3RIjfdqpwIDxXIX6M Q3jEZwRCKbdsmhLRwy7C/Q1ST0ruOLwPsy9m23L6Qny/mJVENoFDApJHGefPkyuF uQ8fHdAGMsNN6wBQgFhtKg0vfjw7+WmNS2W+gZeVoBmv/TvXC9dDN+Bc9bonnevc MCoL4K2mEPnugCnU9Nod2exeFWMPieLAgEEPORVZpcRzOugtJGlgq5gEXE1wLOF8 rcSjIL8HhqUOxVTXJLiMVaILrqD7zmaNNmg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvgedugeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkgggtsehgtderredttddtnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpeeiudffue eilefgtefgtddttdekkeehkefgheekudefveetgeefiefftedvteeuveenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrd hishdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep uggvmhhiohgsvghnohhurhesghhmrghilhdrtghomhdprhgtphhtthhopeguvghvvghlse hsphgvtghtrhhumhdqohhsrdhorhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Nov 2025 07:32:17 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 91B4825FC608; Tue, 25 Nov 2025 13:32:01 +0100 (CET) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH v4 1/2] Build verity images in rootfs Nix derivation In-Reply-To: <87h5ui2t6c.fsf@alyssa.is> References: <20251119-refactor-verity-v4-0-9bc56d5216c0@gmail.com> <20251119-refactor-verity-v4-1-9bc56d5216c0@gmail.com> <87h5ui2t6c.fsf@alyssa.is> Date: Tue, 25 Nov 2025 13:31:34 +0100 Message-ID: <87ecpm2t09.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: O7OXXWFXM3YJXXAEDOHCLAXRO7RUFVDV X-Message-ID-Hash: O7OXXWFXM3YJXXAEDOHCLAXRO7RUFVDV X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Spectrum OS Development X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Whoops, just realised I replied to v4 and not v5. You can ignore this, and I'll resend any comments that are still relevant to v5. Alyssa Ross writes: > Demi Marie Obenour writes: > >> diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile >> index 27a7c689c39bf9bc93b5ba33ce661be7e47b67f1..055185064d84d9450c2076fd= eb410b21d00f1d40 100644 >> --- a/host/rootfs/Makefile >> +++ b/host/rootfs/Makefile >> @@ -1,12 +1,12 @@ >> # SPDX-License-Identifier: EUPL-1.2+ >> # SPDX-FileCopyrightText: 2021-2024 Alyssa Ross >> +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour >>=20=20 >> .POSIX: >>=20=20 >> include ../../lib/common.mk >> include file-list.mk >> - >> -dest =3D build/rootfs.erofs >> +ROOT_FS_DIR =3D build >>=20=20 >> DIRS =3D \ >> dev \ >> @@ -46,15 +46,27 @@ FIFOS =3D etc/s6-linux-init/run-image/service/s6-svs= can-log/fifo >>=20=20 >> BUILD_FILES =3D build/etc/s6-rc >>=20=20 >> -$(dest): ../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUILD_= FILES) build/empty build/fifo file-list.mk >> - set -euo pipefail; \ >> +build/verity-timestamp: $(ROOT_FS) >> + $(VERITYSETUP) format \ >> + --root-hash-file $(ROOT_FS_VERITY_ROOTHASH) \ >> + -- $(ROOT_FS) $(ROOT_FS_VERITY) >> + # Add trailing newline >> + echo >> $(ROOT_FS_VERITY_ROOTHASH) > > Why do we need to do this? > > (Emacs would also rather your comments were not indented, so they're > interpreted by Make as comments rather than being passed on to the > shell.) > >> + touch -- $(ROOT_FS_DIR)/verity-timestamp > > This should be build/verity-timestamp (like the rule), or even better $@. > >> + >> +# This rule produces three files but Make only (portably) >> +# supports one output per rule. Instead of resorting to temporary >> +# files, a timestamp file is created as the last step. The actual >> +# outputs are produced as side-effects. > > Is this comment supposed to be on the previous rule? > >> +$(ROOT_FS): ../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUI= LD_FILES) build/empty build/fifo file-list.mk >> + mkdir -p $(ROOT_FS_DIR) && \ >> { \ >> cat $(PACKAGES_FILE) ;\ >> for file in $(FILES) $(LINKS); do printf '%s\n%s\n' $$file "$${fil= e#image/}"; done ;\ >> for file in $(BUILD_FILES); do printf '%s\n%s\n' $$file $${file#bu= ild/}; done ;\ >> printf 'build/empty\n%s\n' $(DIRS) ;\ >> printf 'build/fifo\n%s\n' $(FIFOS) ;\ >> - } | ../../scripts/make-erofs.sh $@ >> + } | ../../scripts/make-erofs.sh $(ROOT_FS) > > Why change this? > >>=20=20 >> build/fifo: >> mkdir -p build >> @@ -83,25 +95,10 @@ clean: >> rm -rf build >> .PHONY: clean >>=20=20 >> -# veritysetup format produces two files, but Make only (portably) >> -# supports one output per rule, so we combine the two outputs then >> -# define two more rules to separate them again. >> -build/rootfs.verity: $(dest) >> - $(VERITYSETUP) format $(dest) build/rootfs.verity.superblock.tmp \ >> - | awk -F ':[[:blank:]]*' '$$1 =3D=3D "Root hash" {print $$2; exit}= ' \ >> - > build/rootfs.verity.roothash.tmp >> - cat build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tm= p \ >> - > $@ >> - rm build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp >> -build/rootfs.verity.roothash: build/rootfs.verity >> - head -n 1 build/rootfs.verity > $@ >> -build/rootfs.verity.superblock: build/rootfs.verity >> - tail -n +2 build/rootfs.verity > $@ >> - >> -build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh = ../../scripts/sfdisk-field.awk build/rootfs.verity.superblock build/rootfs.= verity.roothash $(dest) >> +build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh = ../../scripts/sfdisk-field.awk $(ROOT_FS_DIR)/verity-timestamp $(ROOT_FS) > > Here you're also still referring to $(ROOT_FS_DIR)/verity-timestamp > rather than build/verity-timestamp. > >> ../../scripts/make-gpt.sh $@.tmp \ >> - build/rootfs.verity.superblock:verity:$$(../../scripts/format-uuid= .sh "$$(dd if=3Dbuild/rootfs.verity.roothash bs=3D32 skip=3D1 count=3D1 sta= tus=3Dnone)") \ >> - $(dest):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 build/= rootfs.verity.roothash)") >> + $(ROOT_FS)/rootfs.verity.superblock:verity:$$(../../scripts/format= -uuid.sh "$$(dd if=3D$(ROOT_FS_VERITY_ROOTHASH) bs=3D32 skip=3D1 count=3D1 = status=3Dnone)") \ >> + $(ROOT_FS)/rootfs:root:$$(../../scripts/format-uuid.sh "$$(head -c= 32 $(ROOT_FS_VERITY_ROOTHASH)") > > This can't be right, can it? $(ROOT_FS) is a file. > >> mv $@.tmp $@ >>=20=20 >> debug: >> @@ -111,7 +108,7 @@ debug: >> $(VMLINUX) >> .PHONY: debug >>=20=20 >> -run: build/live.img build/rootfs.verity.roothash >> +run: build/live.img > > I'd still prefer we kept the explicit dependency, even though we will > get it via build/live.img as well. > >> @set -x && \ >> ext=3D"$$(mktemp build/spectrum-rootfs-extfs.XXXXXXXXXX.img)" && \ >> truncate -s 10G "$$ext" && \ >> @@ -132,7 +129,7 @@ run: build/live.img build/rootfs.verity.roothash >> -device virtconsole,chardev=3Dvirtiocon0 \ >> -drive file=3Dbuild/live.img,if=3Dvirtio,format=3Draw,readonly=3Do= n \ >> -drive file=3D/proc/self/fd/3,if=3Dvirtio,format=3Draw \ >> - -append "earlycon console=3Dhvc0 roothash=3D$$(< build/rootfs.veri= ty.roothash) intel_iommu=3Don nokaslr" \ >> + -append "earlycon console=3Dhvc0 roothash=3D$$(< $(ROOT_FS_VERITY_= ROOTHASH)) intel_iommu=3Don nokaslr" \ >> -device virtio-keyboard \ >> -device virtio-mouse \ >> -device virtio-gpu \ >> diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix >> index 0ac70c7c077c0656c5820a5d8b3c7ce0e7c78e54..1578155fa0fb9a4df3fb4884= e21ed7d8d8f821dc 100644 >> --- a/host/rootfs/default.nix >> +++ b/host/rootfs/default.nix >> @@ -138,7 +138,7 @@ stdenvNoCC.mkDerivation { >> }; >> sourceRoot =3D "source/host/rootfs"; >>=20=20 >> - nativeBuildInputs =3D [ erofs-utils spectrum-build-tools s6-rc ]; >> + nativeBuildInputs =3D [ cryptsetup erofs-utils spectrum-build-tools s= 6-rc ]; >>=20=20 >> env =3D { >> PACKAGES =3D runCommand "packages" {} '' >> @@ -147,7 +147,9 @@ stdenvNoCC.mkDerivation { >> ''; >> }; >>=20=20 >> - makeFlags =3D [ "dest=3D$(out)" ]; >> + # The Makefile uses $(ROOT_FS_DIR), not $(dest), so it can share code >> + # with other Makefiles that also use this variable. >> + makeFlags =3D [ "ROOT_FS_DIR=3D$(out)" ]; >>=20=20 >> dontInstall =3D true; >>=20=20 >> diff --git a/host/rootfs/shell.nix b/host/rootfs/shell.nix >> index 1bf61bebf418333624e799cc8ca231f5783206f4..6df2f575fdfc7cdf8067ccfd= b5fecaad9f6ea5e6 100644 >> --- a/host/rootfs/shell.nix >> +++ b/host/rootfs/shell.nix >> @@ -12,7 +12,7 @@ rootfs.overrideAttrs ( >>=20=20 >> { >> nativeBuildInputs =3D nativeBuildInputs ++ [ >> - btrfs-progs cryptsetup jq netcat qemu_kvm reuse util-linux >> + btrfs-progs jq netcat qemu_kvm reuse util-linux >> ]; >>=20=20 >> env =3D env // { >> diff --git a/lib/common.mk b/lib/common.mk >> index 277c3544036d9a9057f8ba4ad37fe2207548cc59..d1cc4d0514070cc3f418c4d1= b7e929abd40d985c 100644 >> --- a/lib/common.mk >> +++ b/lib/common.mk >> @@ -11,6 +11,10 @@ GDB =3D gdb >> MCOPY =3D mcopy >> MKFS_FAT =3D mkfs.fat >> MMD =3D mmd >> +ROOT_FS =3D $(ROOT_FS_DIR)/rootfs > > Would be nice for this to keep its file extension. > >> +ROOT_FS_IMAGES =3D $(ROOT_FS) $(ROOT_FS_VERITY_ROOTHASH) $(ROOT_FS_VERI= TY) > > I'm not sure "IMAGES" makes sense as a name for this. A verity roothash > is not an image. ROOT_FS_FILES? > > Alternative naming scheme idea, that avoids mistaking ROOT_FS for the > directory like has happened above: > > ROOT_FS (for the directory), ROOT_FS_IMAGE, ROOT_FS_VERITY, > ROOT_FS_VERITY_ROOTHASH. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQGoGac7QfI+H5ZtFCZddwkt31pFQUCaSWhpgAKCRCZddwkt31p FcQ0APwNaBwz/D/LvmHi6PfVM9zmPSEfqh/WbGK+wyxQVV5m3QEAirxXDx8qxj6g H4mR05jrDtUaNHuowgdXtmhEzw67Wwk= =rzpA -----END PGP SIGNATURE----- --=-=-=--