From: Demi Marie Obenour <demiobenour@gmail.com>
To: Alyssa Ross <hi@alyssa.is>
Cc: Spectrum OS Development <devel@spectrum-os.org>
Subject: Re: [PATCH 11/20] Add /dev/fd and /dev/std*
Date: Mon, 8 Sep 2025 14:12:08 -0400 [thread overview]
Message-ID: <a0bebb66-1ae9-45fe-aa2b-1012b63872d7@gmail.com> (raw)
In-Reply-To: <87h5xdjo9p.fsf@alyssa.is>
[-- Attachment #1.1.1: Type: text/plain, Size: 3664 bytes --]
On 9/8/25 05:18, Alyssa Ross wrote:
> Demi Marie Obenour <demiobenour@gmail.com> 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 <demiobenour@gmail.com>
>
> This is really two independent patches in one as well.
Will fix.
>> ---
>> 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..b72108ab96630e2a846063551772b0b29ca27bdf 100755
>> --- a/host/initramfs/etc/init
>> +++ b/host/initramfs/etc/init
>> @@ -6,6 +6,11 @@ export PATH /bin
>>
>> if { mount -a }
>>
>> +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.
Is there a plan to run Spectrum OS without an initramfs?
If not, then adding these can only help and cannot hurt.
>> 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 }
>>
>> -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.
Does Busybox switch_root already move these mounts?
I know util-linux switch_root does.
>> switch_root /mnt/root
>> /etc/init
>> diff --git a/vm/sys/net/etc/s6-linux-init/scripts/rc.init b/vm/sys/net/etc/s6-linux-init/scripts/rc.init
>> index 1016d0c62bc6103bc9e865a389f5d482ef6c2b76..eaf037ec123afcaeafced93096c4f35c2388f385 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 <hi@alyssa.is>
>>
>> +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 }
>>
>> if { mkdir -p /dev/pts /dev/shm }
>>
>> --
>> 2.51.0
--
Sincerely,
Demi Marie Obenour (she/her/hers)
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-09-08 18:12 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 21:26 [PATCH 00/20] Many image fixes and systemd integration Demi Marie Obenour
2025-09-04 21:26 ` [PATCH 01/20] scripts/make-erofs.sh: Ensure that / is world-readable Demi Marie Obenour
2025-09-08 8:21 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 02/20] scripts/make-erofs.sh: Do not read one byte at a time Demi Marie Obenour
2025-09-08 8:23 ` Alyssa Ross
2025-09-08 16:57 ` Demi Marie Obenour
2025-09-09 15:19 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 03/20] scripts/make-erofs.sh: Avoid unneeded calls to awk and chmod Demi Marie Obenour
2025-09-08 8:28 ` Alyssa Ross
2025-09-08 17:14 ` Demi Marie Obenour
2025-09-10 18:45 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 04/20] scripts/make-erofs.sh: Validate all paths Demi Marie Obenour
2025-09-08 8:36 ` Alyssa Ross
2025-09-08 18:21 ` Demi Marie Obenour
2025-09-10 18:54 ` Alyssa Ross
2025-09-21 12:09 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 05/20] scripts/make-erofs.sh: Avoid unneeded calls to dirname Demi Marie Obenour
2025-09-10 20:04 ` Alyssa Ross
2025-09-10 20:06 ` Demi Marie Obenour
2025-09-19 16:47 ` Alyssa Ross
2025-09-19 19:04 ` Demi Marie Obenour
2025-09-04 21:26 ` [PATCH 06/20] scripts/make-erofs.sh: Avoid unneeded calls to mkdir Demi Marie Obenour
2025-09-08 8:39 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 07/20] scripts/make-erofs.sh: Standardize file modes in images Demi Marie Obenour
2025-09-08 8:46 ` Alyssa Ross
2025-09-08 17:16 ` Demi Marie Obenour
2025-09-19 17:50 ` Alyssa Ross
2025-09-19 19:18 ` Demi Marie Obenour
2025-09-21 12:23 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 08/20] Standardize directories and symlinks " Demi Marie Obenour
2025-09-08 8:59 ` Alyssa Ross
2025-09-08 18:05 ` Demi Marie Obenour
2025-09-19 17:53 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 09/20] Add os-release file Demi Marie Obenour
2025-09-08 9:12 ` Alyssa Ross
2025-09-08 18:07 ` Demi Marie Obenour
2025-09-04 21:26 ` [PATCH 10/20] host/rootfs: Set -eu in build Demi Marie Obenour
2025-09-08 9:13 ` Alyssa Ross
2025-09-08 18:08 ` Demi Marie Obenour
2025-09-04 21:26 ` [PATCH 11/20] Add /dev/fd and /dev/std* Demi Marie Obenour
2025-09-08 9:18 ` Alyssa Ross
2025-09-08 18:12 ` Demi Marie Obenour [this message]
2025-09-04 21:26 ` [PATCH 12/20] host/rootfs: Do not read from /dev/tty1 Demi Marie Obenour
2025-09-08 9:19 ` Alyssa Ross
2025-09-08 18:18 ` Demi Marie Obenour
2025-09-19 18:22 ` Alyssa Ross
2025-09-19 19:00 ` Demi Marie Obenour
2025-09-21 9:01 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 13/20] host/rootfs: pass API socket as fd 3, not fd 0 Demi Marie Obenour
2025-09-08 9:44 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 14/20] host/rootfs: Disable unneeded BusyBox tools Demi Marie Obenour
2025-09-08 9:24 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 15/20] host/rootfs: Use real less, not BusyBox less Demi Marie Obenour
2025-09-08 9:25 ` Alyssa Ross
2025-09-08 18:16 ` Demi Marie Obenour
2025-09-19 18:45 ` Alyssa Ross
2025-09-19 19:01 ` Demi Marie Obenour
2025-09-21 9:02 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 16/20] host/rootfs: explicitly set PATH in network add script Demi Marie Obenour
2025-09-04 21:26 ` [PATCH 17/20] Use /etc/s6-rc/compiled for compiled s6-rc directory Demi Marie Obenour
2025-09-08 9:27 ` Alyssa Ross
2025-09-08 18:15 ` Demi Marie Obenour
2025-09-04 21:26 ` [PATCH 18/20] host/rootfs: virtiofsd: Do not use FD 0 as the socket Demi Marie Obenour
2025-09-08 9:44 ` Alyssa Ross
2025-09-04 21:26 ` [PATCH 19/20] host/rootfs: Disable unneeded busybox stuff Demi Marie Obenour
2025-09-04 21:26 ` [PATCH 20/20] host/rootfs: Switch to systemd Demi Marie Obenour
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0bebb66-1ae9-45fe-aa2b-1012b63872d7@gmail.com \
--to=demiobenour@gmail.com \
--cc=devel@spectrum-os.org \
--cc=hi@alyssa.is \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).