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 477A919C8E; Mon, 08 Sep 2025 09:18:33 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id BD20E19BF1; Mon, 08 Sep 2025 09:18:30 +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,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) by atuin.qyliss.net (Postfix) with ESMTPS id 080A919C11 for ; Mon, 08 Sep 2025 09:18:30 +0000 (UTC) Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id E695F1D000C8; Mon, 8 Sep 2025 05:18:28 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Mon, 08 Sep 2025 05:18:29 -0400 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=fm3; t=1757323108; x=1757409508; bh=7ihbkLoiQy 9kWTs2u42n5w8VSUQfXiLfw8rWUfZVcp8=; b=kL6uYSgVjSwbemppUpXwszeDze uPlLCcGnVlOdN1vTn2hpTLJ+aTbQCtSPpyMVz5TWlxx+FORq0hGlP0GbeTOmD7rn +DZ7G+v52j0YjFAXLI8fgPI8RXFBaOMn4RtGntux01dxesbWXFoJDLsYtc65Aegk nY2SBNiWvFKqvuStXWVCP0e0RjSpKnn2ZIhewg+DNJxyDizVePVTwufEAUtn/jVc WXvwGhFjormSIK3P8FiANe1s4ugStJHSihUubifJEJ89CObK4gruvm+PzyrTMhs/ Y6IIhfd2EUi4MgdMmpy//yvD+IDJCkgkjfzr5eDs3Sm+O3imlRRMs49CBSeA== 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=fm1; t= 1757323108; x=1757409508; bh=7ihbkLoiQy9kWTs2u42n5w8VSUQfXiLfw8r WUfZVcp8=; b=HhL2UwsHrsru9UKtfxV1Z1UQWTyj64X4cggjMXh6CslqWPvgbnM Mk4o3EsS5i7lkh9nQltaH7kd0h1ph3tJ9yeUddNH23IxAS4v3a1KxdJYl6kHEUym WtAxTj5DQ5n/758gMZ2T2W1wMMBybRZL7S1oYBD+3+ycqbC4sqLgh89VfpsTqQYZ +wSlW3hjTPbWD8lpA97/YLhv3BZj2jMEuZGOP7xCKMQsbAE5MI9qimPzwj/0qTpj ofPdXErx/o0B5zEJmLOA87iCs8O7DILnhP4vpIkYHffHiESwPmtHBva4CO6Qh2Um ULrqQPUGQpSGqtA8Y8Pt9kylwXRft7ya73g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddujeduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufgjfhffkfggtgesghdtreertddttdenucfhrhhomheptehlhihsshgrucft ohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepieduffeuie elgfetgfdttddtkeekheekgfehkedufeevteegfeeiffetvdetueevnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhephhhisegrlhihshhsrgdrih hspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegu vghmihhosggvnhhouhhrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepuggvvhgvlhessh hpvggtthhruhhmqdhoshdrohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 Sep 2025 05:18:28 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id E24AD1674F80; Mon, 08 Sep 2025 11:18:26 +0200 (CEST) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH 11/20] Add /dev/fd and /dev/std* In-Reply-To: <20250904-systemd-v1-11-2a63b790a913@gmail.com> References: <20250904-systemd-v1-0-2a63b790a913@gmail.com> <20250904-systemd-v1-11-2a63b790a913@gmail.com> Date: Mon, 08 Sep 2025 11:18:26 +0200 Message-ID: <87h5xdjo9p.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: IRULSQBHNDRE2YU54WSB6YF6WDUC3SCB X-Message-ID-Hash: IRULSQBHNDRE2YU54WSB6YF6WDUC3SCB 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 Demi Marie Obenour writes: > This is the same as 14483e1a690c (img/app: add /dev/fd and /dev/std*), > but for the host and for vm/sys/net. While only Spectrum-provided code > should run in these VMs, third-party dependencies of Spectrum might > assume these links exist, and them being missing could cause severe > bugs. For instance, code writing to /dev/stdout could create a file in > /dev rather than actually writing to stdout. > > In the host, the links are added in the initramfs. Since /dev is > created by the kernel and moved (via mount --move) from the initramfs to > the main system, adding the links in the main system is not necessary > and in fact would fail. > > Also reorder the moving of /sys, /proc, and /dev from the initramfs to > the root filesystem to minimize the time that /dev and /proc are not > mounted. /proc is considered more important than /dev. > > Signed-off-by: Demi Marie Obenour This is really two independent patches in one as well. > --- > host/initramfs/etc/init | 7 ++++++- > vm/sys/net/etc/s6-linux-init/scripts/rc.init | 5 +++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/host/initramfs/etc/init b/host/initramfs/etc/init > index 719488741b6d31564c2c17c0e41f15d16b1c0a08..b72108ab96630e2a846063551= 772b0b29ca27bdf 100755 > --- a/host/initramfs/etc/init > +++ b/host/initramfs/etc/init > @@ -6,6 +6,11 @@ export PATH /bin >=20=20 > if { mount -a } >=20=20 > +if { ln -s /proc/self/fd /dev } > +if { ln -s /proc/self/fd/0 /dev/stdin } > +if { ln -s /proc/self/fd/1 /dev/stdout } > +if { ln -s /proc/self/fd/2 /dev/stderr } > + Would prefer to do this in host/rootfs, in the interest of not creating more implicit requirements on initramfs in that system. initramfs is deterministic enough that it's vanishingly unlikely we'll find that it requires these only sometimes. > piperw 3 4 > if { fdmove 1 4 /etc/getuuids } > fdclose 4 > @@ -45,9 +50,9 @@ background { rm /dev/rootfs /dev/verity } > if { mount /dev/mapper/root-verity /mnt/root } > wait { $mdevd_pid } >=20=20 > -if { mount --move /proc /mnt/root/proc } > if { mount --move /sys /mnt/root/sys } > if { mount --move /dev /mnt/root/dev } > +if { mount --move /proc /mnt/root/proc } I don't understand this. There are no other processes running, so how could the order possibly matter? There's nothing to race against. >=20=20 > switch_root /mnt/root > /etc/init > diff --git a/vm/sys/net/etc/s6-linux-init/scripts/rc.init b/vm/sys/net/et= c/s6-linux-init/scripts/rc.init > index 1016d0c62bc6103bc9e865a389f5d482ef6c2b76..eaf037ec123afcaeafced9309= 6c4f35c2388f385 100755 > --- a/vm/sys/net/etc/s6-linux-init/scripts/rc.init > +++ b/vm/sys/net/etc/s6-linux-init/scripts/rc.init > @@ -2,6 +2,11 @@ > # SPDX-License-Identifier: EUPL-1.2+ > # SPDX-FileCopyrightText: 2020-2022 Alyssa Ross >=20=20 > +if { ln -s /proc/self/fd /dev } > +if { ln -s /proc/self/fd/0 /dev/stdin } > +if { ln -s /proc/self/fd/1 /dev/stdout } > +if { ln -s /proc/self/fd/2 /dev/stderr } > + > if { s6-rc-init -c /etc/s6-rc /run/service } >=20=20 > if { mkdir -p /dev/pts /dev/shm } > > --=20 > 2.51.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaL6fYgAKCRBbRZGEIw/w on1vAQCMmoHdT23NLfZOEdyvI8w78KByR61xuKqG9q5r76QbmAD/crFupAvZ06Hz KUHl+SC+TBjEkbNQ6vavrVZDoi86MAs= =mXP9 -----END PGP SIGNATURE----- --=-=-=--