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 7F4741BD55; Thu, 18 Sep 2025 19:45:57 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 86E4B1BD34; Thu, 18 Sep 2025 19:45:54 +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,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by atuin.qyliss.net (Postfix) with ESMTPS id 293C11BD31 for ; Thu, 18 Sep 2025 19:45:53 +0000 (UTC) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-71d603a9cfaso10838247b3.1 for ; Thu, 18 Sep 2025 12:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758224752; x=1758829552; darn=spectrum-os.org; h=cc:to:references:in-reply-to:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LoZ9Mu7qxfQ7UmgdurRhHhqhbbDpB+rsh5RsVqLBMnc=; b=EpXfXkaZU6c9LVX4fDJcWCX3qMlN9tfa8M5YBhgkWd+mawneqMO7iWRTazAZvUYy2z PktO6DQBweLGSCApwOWQgyskACLOfsFfpSYT7RzxBkmXYPNpPGd7Ohrfxixf5vLVTwCv dmHXLyWeS8qtUj1KPuSlHrCjaQNzSTmXnEGCXD5fCquxZgeNbzHwrHsiEfq0GN+TPtov vAQS+R2Z4qy7Bp3SXmzv4hiPWOs1bVJ7/DWgjMscIESiYreUXR+E9QNjwlJu2H8RoAlg OjlywSnIy0qccAmj7OdaMYlYgqDtX+eJDwImgChOEYLyLvPB+f/rkf1sVCBFjlVv8+04 hH4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758224752; x=1758829552; h=cc:to:references:in-reply-to:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LoZ9Mu7qxfQ7UmgdurRhHhqhbbDpB+rsh5RsVqLBMnc=; b=jG20sfkCX/i7CWiAWqPzDfYvP0KVsS4eeqOUl2My92stfAxuQfCR5CKRgB9duqjmEV oz9vcOW37LIFW7hrE1dYp9ZRrjkZGLMu9j3epJIF4Gdg3iZIvEJ6delsLS90rtaGq3vM ecEWUbOqhk3hyfniIVrcEuU5F6zS4vMY/r6CbZLawpFPppljMu1xlgBazfsv8htucNR4 CoW23JabQcLMwBODONpnt8BPdxx+rPtR7LVs2gAT2zpCnJbSEr4z+CuRtoVNS96+awA0 fhcwmZTgkZ8Tm+UBgvuiCJIwRXGF0X8ZIPgvPAIkIiiqtv0u1g0nd6lis8lD4kNGLt6e 6uoQ== X-Gm-Message-State: AOJu0YykFS4xEEYQMb33cyYTN38GBOjjxRdBwGdoVvVlI9PQInj/K2Y7 OwRoQH1tQ3hBqn4ah2w0iPPn3wH0t5Gu9Vz8ywFI82YtlreaGsNz/DheBh+qxw== X-Gm-Gg: ASbGncuZn3MIe3LYdfel651/1IIwRWbuJBd/iCVaGU/75CU+4ISOL7WBYuN3sb2Y5dp Q9+fZhRSJocMgPRepDGhza1JVgK7DhNUUdBdZalmxxGpxrWN7XpTaC13hNGvRgsSes06d4dGUH1 RWTo2wKeBUe4pnyUK+ws2Rc3NwU9niXPXD+eLoPJSnjwL/J62Ua9xszrQBXFThqZbPg5+Jg1Lbk rVdFf1mLujA4oJz9AUYAJFUWb3T4w90gIiHwoMHfeIijoxgYiCX22YW5lACg6DXvlX2H2s3653b E8JLVN4iyy/H/yqZhGjDGbu+0prLrm5MlG9M6h/668lpsrxsYSCHl+lzqqa802f1fS7GCBNPwLh +bzFJl2XHGvm6d7OBX/w4dvYEI1M6eZlYxHkuKJYiUIEdwSS4S2KHzBZiFQoUa21cO8bmHHKoGT RHj9S8WmWpybVxC9qcYuT3RDgZI2+aZTci83QvHI7mkM7XSshCVAKw0FgGjzFyog== X-Google-Smtp-Source: AGHT+IGdQvyoTN65/a4H7ojXAtPfj0xE/rRe8M8NcV320UJ4s/9vnGzh7GtY77Ild2YN+rXPCuH2XA== X-Received: by 2002:a05:690c:3507:b0:729:df2d:4a23 with SMTP id 00721157ae682-73d3a52a51amr7040807b3.32.1758224751643; Thu, 18 Sep 2025 12:45:51 -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 00721157ae682-739718f3604sm8981107b3.73.2025.09.18.12.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Sep 2025 12:45:51 -0700 (PDT) From: Demi Marie Obenour Date: Thu, 18 Sep 2025 15:45:01 -0400 Subject: [PATCH v2] Add /dev/fd and /dev/std* MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250918-util-linux-switch-root-v2-1-762ac91ea24b@gmail.com> X-B4-Tracking: v=1; b=H4sIAD1hzGgC/4WNQQ6DIBBFr2Jm3WlAcUFXvUfjQinKJAgNILUx3 L3UC3T5XvLfPyDqQDrCrTkg6EyRvKvQXhpQZnSLRnpWhpa1PZNc4JbIoiW37RjflJTB4H1Czlg nJi6kFj3U8SvomfYz/BgqG4rJh8/5k/nP/k1mjgylmmUnpJrU2N2XdSR7VX6FoZTyBSXFG268A AAA X-Change-ID: 20250914-util-linux-switch-root-10034b149e45 In-Reply-To: <20250914-util-linux-switch-root-v1-0-9cf9349cbca3@gmail.com> References: <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=1758224701; l=2893; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=xzmeDOO9C9qL5Si4o9SDU6j9MozDV60f2eZEPGXPFiY=; b=W8/keouvju2WnfpZXDyrAQQyb/Ybgs3Q+9PeAdk5ooKarPUiwhI7pUTPJTSgJQdTk4tzHhOgu 2YtBI72mD9fC1AF6dR5E0HUAd0DBrKGtg7893GHODI7XoQVxDw8unt0 X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: ZPNNVB7EABZZUFTUBH47LXGMDB47OFDD X-Message-ID-Hash: ZPNNVB7EABZZUFTUBH47LXGMDB47OFDD 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: Alyssa Ross , Demi Marie Obenour 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. [1]: https://spectrum-os.org/lists/archives/spectrum-devel/87h5xdjo9p.fsf@alyssa.is/ Signed-off-by: Demi Marie Obenour --- Changes in v2: - Do not switch to util-linux switch_root as Busybox switch_root is good enough. - Leave /proc and /sys in /etc/fstab as they will not be remounted if already mounted. - Link to v1: https://spectrum-os.org/lists/archives/spectrum-devel/20250914-util-linux-switch-root-v1-0-9cf9349cbca3@gmail.com --- host/rootfs/image/etc/s6-linux-init/scripts/rc.init | 5 +++++ vm/sys/net/image/etc/s6-linux-init/scripts/rc.init | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/host/rootfs/image/etc/s6-linux-init/scripts/rc.init b/host/rootfs/image/etc/s6-linux-init/scripts/rc.init index 674fd38cc76837c7be25a5ef060f0f4d4b786394..46e5cd6d1b99c12fab84a2797b37d9f4eccaa56a 100755 --- a/host/rootfs/image/etc/s6-linux-init/scripts/rc.init +++ b/host/rootfs/image/etc/s6-linux-init/scripts/rc.init @@ -4,6 +4,11 @@ if { s6-rc-init -c /etc/s6-rc /run/service } +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 { mount --make-shared /run } if { mount -a --mkdir } diff --git a/vm/sys/net/image/etc/s6-linux-init/scripts/rc.init b/vm/sys/net/image/etc/s6-linux-init/scripts/rc.init index 1016d0c62bc6103bc9e865a389f5d482ef6c2b76..4378400b0b34f12bfa6a994029546f9c38058d10 100755 --- a/vm/sys/net/image/etc/s6-linux-init/scripts/rc.init +++ b/vm/sys/net/image/etc/s6-linux-init/scripts/rc.init @@ -4,6 +4,11 @@ if { s6-rc-init -c /etc/s6-rc /run/service } +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 { mkdir -p /dev/pts /dev/shm } if { mount -a } --- base-commit: edd53bb5dd9b682fec744d6df7921b64e0f56565 change-id: 20250914-util-linux-switch-root-10034b149e45 -- Sincerely, Demi Marie Obenour (she/her/hers)