From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [PATCH 6/6] host/rootfs: run crosvm device gpu as non-root
Date: Tue, 9 Dec 2025 11:42:57 +0100 [thread overview]
Message-ID: <20251209104429.663637-1-hi@alyssa.is> (raw)
In-Reply-To: <20251209085628.603316-1-hi@alyssa.is>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
.../template/data/service/vhost-user-gpu/run | 11 +++++++++--
host/rootfs/image/usr/bin/run-appimage | 1 +
host/rootfs/image/usr/bin/run-flatpak | 1 +
host/rootfs/image/usr/bin/vm-import | 1 +
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run
index 6ee99599..1341691b 100755
--- a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run
+++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run
@@ -3,9 +3,16 @@
# SPDX-FileCopyrightText: 2025 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
-s6-ipcserver -1a 0700 -c 1 -b 1 env/crosvm.sock
+s6-ipcserver-socketbinder -a 0700 -b 1 env/crosvm.sock
-importas -Si WAYLAND_DISPLAY
+multisubstitute {
+ importas -Siu VM
+ importas -Si WAYLAND_DISPLAY
+}
+
+s6-envuidgid gpu-${VM}
+s6-applyuidgid -UzG 15 # wayland
+s6-ipcserverd -1c 1
bwrap
--unshare-all
diff --git a/host/rootfs/image/usr/bin/run-appimage b/host/rootfs/image/usr/bin/run-appimage
index f2fe7bc2..36f57b85 100755
--- a/host/rootfs/image/usr/bin/run-appimage
+++ b/host/rootfs/image/usr/bin/run-appimage
@@ -4,6 +4,7 @@
backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX }
backtick -E id { basename -- $dir }
+if { useradd -P /run -Urd / -s /bin/nologin gpu-${id} }
if { mkdir -p /run/configs/${id}/fs }
diff --git a/host/rootfs/image/usr/bin/run-flatpak b/host/rootfs/image/usr/bin/run-flatpak
index d7914a7a..2ef20433 100755
--- a/host/rootfs/image/usr/bin/run-flatpak
+++ b/host/rootfs/image/usr/bin/run-flatpak
@@ -4,6 +4,7 @@
backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX }
backtick -E id { basename -- $dir }
+if { useradd -P /run -Urd / -s /bin/nologin gpu-${id} }
if {
elgetpositionals
diff --git a/host/rootfs/image/usr/bin/vm-import b/host/rootfs/image/usr/bin/vm-import
index c1d1bbc1..19a0df36 100755
--- a/host/rootfs/image/usr/bin/vm-import
+++ b/host/rootfs/image/usr/bin/vm-import
@@ -9,6 +9,7 @@ forx -po0 -E name { $names }
backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX }
backtick -E id { basename -- $dir }
+if { useradd -P /run -Urd / -s /bin/nologin gpu-${id} }
if { ln -s -- ${dir} /run/vm/by-name/${1}.${name} }
if { ln -s -- ${2}/${name} ${dir}/config }
--
2.51.0
next prev parent reply other threads:[~2025-12-09 10:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 8:56 [PATCH 1/5] host/rootfs: make passwd and group links into /run Alyssa Ross
2025-12-09 8:56 ` [PATCH 2/5] host/rootfs: install shadow Alyssa Ross
2025-12-09 8:56 ` [PATCH 3/5] host/rootfs: move Wayland out of XDG_RUNTIME_DIR Alyssa Ross
2025-12-09 8:56 ` [PATCH 4/5] host/rootfs: weston: add XDG_RUNTIME_DIR note Alyssa Ross
2025-12-09 8:56 ` [PATCH 5/5] host/rootfs: add wayland group Alyssa Ross
2025-12-09 10:55 ` Demi Marie Obenour
2025-12-09 10:59 ` Alyssa Ross
2025-12-09 11:02 ` Demi Marie Obenour
2025-12-09 11:09 ` Alyssa Ross
2025-12-09 10:42 ` Alyssa Ross [this message]
2025-12-09 10:52 ` [PATCH 1/5] host/rootfs: make passwd and group links into /run Demi Marie Obenour
2025-12-09 10:57 ` Alyssa Ross
2025-12-09 11:03 ` Demi Marie Obenour
2025-12-09 11:11 ` Alyssa Ross
2025-12-09 11:15 ` 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=20251209104429.663637-1-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
/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).