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 870A14A43; Mon, 15 Sep 2025 00:20:39 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 8BAD44A09; Mon, 15 Sep 2025 00:20:36 +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.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yx1-xb129.google.com (mail-yx1-xb129.google.com [IPv6:2607:f8b0:4864:20::b129]) by atuin.qyliss.net (Postfix) with ESMTPS id 648B1499F for ; Mon, 15 Sep 2025 00:20:32 +0000 (UTC) Received: by mail-yx1-xb129.google.com with SMTP id 956f58d0204a3-60f476eab6cso1841829d50.2 for ; Sun, 14 Sep 2025 17:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757895631; x=1758500431; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FejH7HQiXU9s48yPuroYai4ogJA28Jwz0Z0nAmVK/0Y=; b=QEuX1vFODXQlJtJH+hXj6fBSSj61h5QH1+F0Wcha9FRQWB5PcrNZPbkzws5zqpcvAR B9GoEOEpjhH7H7xbyo7PiXU7a7xh/3joFynRJiVXrg4rtvlcwmeaSn6soeNceLTeqaOM V1nrvxA5oaZYuz7sKaB7QdtBq1P3Rh/MHSmY0KGN6cvv8nDoPY0tV/e8Tj4k/K8pCrUu EGju9EZUKE+DZr/vrxn+PbMUJYs8rtxcQ6ii/gMvbXQQMgttWGmix8shbTncIXb6S8RI Li0fiJXdauTAWMSYCZa9hHsIVtD88FP9mNgvizGObL34SSKbv/2o1ZdFKcD7JahbLEB8 t+wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757895631; x=1758500431; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FejH7HQiXU9s48yPuroYai4ogJA28Jwz0Z0nAmVK/0Y=; b=qG+71DlmYoD6dvDHCvc3/rE1mmp1dc80rnRwGGNHtiXLAJ8mmdil/IvxhuNjXllmVI QSMfvVv/Yx0FETi07+j2iNgrX+BB6pAXRHYro2B56KK2y9PlhO0ypFHlda4/oQ+F9wqK pYefV6pvP5TbcOmshHpaaEqcJDEaOHWoeCFyfn63SJTp/BexdCSFiPUdiK0jYbmr4zMT 0TLmxGvb8UviI0RsnJvdmI+8zEY9P+JttEkquYFacr24A4Zt4lZq4YADNffD90tedwXC 63CwvPaAdWHxRu7+vpBE0HW0/JW24snUnzBzDJ/hCN+SuhoHrPfrLdaTcLZH0ctYVYq6 D5qg== X-Gm-Message-State: AOJu0Yx3Bz/Z9kNvFeeauFk7S4YO44tQtZcmuTN7uFXRkIwZYIBN9WTd eJB/77PwWfK99IRguCF52/7zxy1jErP84ZadicnJTSUIoPJaWCDzrjhuvKNJaBwf X-Gm-Gg: ASbGncs0587/ioj9MPxwaCA6OQgXeFz1TCJXijE9/9QPqmtrwLErJJRdKGomrFUBoY1 AmJeZ6/PIBBzSzSvD+uxrUDbpLhtzljIEPMXP71X4KyeJlbEIvf8hePVW+Ihdx+ysRJ8cDSC2Dk VTYnzX4esTjZSo8HLclONd8MYFCIetaGUXOZQJY2XFxqKGNbXRP3craI9ww1KB+gVkkLAfqxPF3 VlM+X7kimOn8j1AAMFWSqa6x/Vsu625hmePfk8Jv4LIDwopzDj6PGHJP1CgGDDf8oZxHlUs00Ts HVp8eOeneH2dMy+qF7ebGE/S0bThRUGtH6/LVVJIHADPqSpzcNbs943NklxBWf0nbNdWWGMoLiX 7JsbK+FjwTlynLR9cXdqiZxqRf9ghOAf+vHZrmJeLJtWucUTqjDyWwZ1hb7JuzbEmSIWvh38rBN DhNzIqsBeVk+AstcOfZQ5Orn0U55ybv+ZNqNPujqgmzRGfzFZJiS2arA== X-Google-Smtp-Source: AGHT+IFiNpQA1iBs2/K9jbLEcqUQE0eh1DOrtFFA2o97wQoAPxdQYYOW9eOAE4czOlIEdlBRDMuzDA== X-Received: by 2002:a05:690e:1509:b0:62f:25c4:2bf1 with SMTP id 956f58d0204a3-62f25c435a1mr2601620d50.22.1757895631152; Sun, 14 Sep 2025 17:20:31 -0700 (PDT) Received: from localhost.localdomain (h96-60-249-169.cncrtn.broadband.dynamic.tds.net. [96.60.249.169]) by smtp.gmail.com with UTF8SMTPSA id 956f58d0204a3-6289ce42c3asm2242351d50.5.2025.09.14.17.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Sep 2025 17:20:30 -0700 (PDT) From: Demi Marie Obenour Date: Sun, 14 Sep 2025 20:18:59 -0400 Subject: [PATCH 2/3] Add /dev/fd and /dev/std* MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250914-util-linux-switch-root-v1-2-9cf9349cbca3@gmail.com> References: <20250914-util-linux-switch-root-v1-0-9cf9349cbca3@gmail.com> In-Reply-To: <20250914-util-linux-switch-root-v1-0-9cf9349cbca3@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757895537; l=2834; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=NgkX9DoftQmzJnTTHs4GaZagJ6aHSddeSV3Kn3i1S8I=; b=bHxmPzfFlIY89B6CSNOzRKh5dZ1U8xtPrDOdqHwv6j+ZS/gZz7Edmui05oGcYXqmNQ+ReKOeN 4G9luti0vgaDqu5kIr4EJs9rKxSPfmgjz8wDWI3dCBrwszhpYUF9Ies X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: 53R3UVIEATEUVNOQYRDJ7L35R22NOVZK X-Message-ID-Hash: 53R3UVIEATEUVNOQYRDJ7L35R22NOVZK X-MailFrom: demiobenour@gmail.com 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: Demi Marie Obenour , Alyssa Ross 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: This is nearly same as 14483e1a690c (img/app: add /dev/fd and /dev/std*), but for the host and for vm/sys/net. The only difference is that the symlinks are created in init, rather than in rc.init. This ensures that nothing in the main system can run before they the links are created. While only Spectrum-provided code should run in these VMs, third-party dependencies are likely to only be tested in an environment where these links are present. Since the BSDs also have these links, some code might even use them on purpose. Not having these links could cause severe bugs. For instance, if /dev/stdout or /dev/stderr is missing, writing to them will create a regular file instead. This could cause other code to misbehave. Furthermore, /dev is a devtmpfs, so this could consume a lot of memory. In the host, the links are added in the main system, rather than in the initramfs. This is per Alyssa's suggestion in [1]. [1]: https://spectrum-os.org/lists/archives/spectrum-devel/87h5xdjo9p.fsf@alyssa.is/ Signed-off-by: Demi Marie Obenour --- host/rootfs/etc/init | 8 ++++++++ vm/sys/net/etc/init | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/host/rootfs/etc/init b/host/rootfs/etc/init index 4085fa55545e7309004967e443e47fc2b82b0663..b6e6122ddb987a5463c0924cd56e1a26cf5bfd98 100755 --- a/host/rootfs/etc/init +++ b/host/rootfs/etc/init @@ -1,5 +1,13 @@ #!/bin/execlineb -s0 # SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2022 Alyssa Ross +# Symlink creation (if it's copyrightable): +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour + +/usr/bin/if { /usr/bin/ln -s /proc/self/fd /dev } +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/0 /dev/stdin } +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/1 /dev/stdout } +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/2 /dev/stderr } /bin/s6-linux-init -c /etc/s6-linux-init -s /run/param -- $@ diff --git a/vm/sys/net/etc/init b/vm/sys/net/etc/init index 6424e221e0fb929e107271bd52b61706b9f1855e..de409e9296a24d42cef50605496efc520790559e 100755 --- a/vm/sys/net/etc/init +++ b/vm/sys/net/etc/init @@ -1,5 +1,13 @@ #!/bin/execlineb -s0 # SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2022 Alyssa Ross +# Symlink creation (if it's copyrightable): +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour + +/usr/bin/if { /usr/bin/ln -s /proc/self/fd /dev } +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/0 /dev/stdin } +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/1 /dev/stdout } +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/2 /dev/stderr } /bin/s6-linux-init -Bc /etc/s6-linux-init -- $@ -- 2.51.0