patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [PATCH] tools/start-vmm: enable Cloud Hypervisor landlock
Date: Mon, 10 Nov 2025 19:49:07 +0100	[thread overview]
Message-ID: <20251110184907.346511-1-hi@alyssa.is> (raw)

We can't really predict the device paths or IOMMU groups statically,
so this is as good as it gets with landlock rules.  We'll be able to
do other things to further lock things down though, like running
different Cloud Hypervisor instances as different users, and changing
ownership of each IOMMU group in /dev/vfio/vfio to match.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
 tools/start-vmm/ch.rs  |  8 ++++++++
 tools/start-vmm/lib.rs | 15 +++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/tools/start-vmm/ch.rs b/tools/start-vmm/ch.rs
index 80e75dc..ed2d457 100644
--- a/tools/start-vmm/ch.rs
+++ b/tools/start-vmm/ch.rs
@@ -69,6 +69,12 @@ pub struct VsockConfig {
     pub socket: String,
 }
 
+#[derive(Serialize)]
+pub struct LandlockConfig {
+    pub path: String,
+    pub access: &'static str,
+}
+
 #[derive(Serialize)]
 pub struct VmConfig {
     pub console: ConsoleConfig,
@@ -80,6 +86,8 @@ pub struct VmConfig {
     pub payload: PayloadConfig,
     pub serial: ConsoleConfig,
     pub vsock: VsockConfig,
+    pub landlock_enable: bool,
+    pub landlock_rules: Vec<LandlockConfig>,
 }
 
 fn command(vm_dir: &Path, s: impl AsRef<OsStr>) -> Command {
diff --git a/tools/start-vmm/lib.rs b/tools/start-vmm/lib.rs
index 5dc5ae7..9a77780 100644
--- a/tools/start-vmm/lib.rs
+++ b/tools/start-vmm/lib.rs
@@ -14,8 +14,8 @@ use std::io::{self, ErrorKind};
 use std::path::Path;
 
 use ch::{
-    ConsoleConfig, DiskConfig, FsConfig, GpuConfig, MemoryConfig, PayloadConfig, VmConfig,
-    VsockConfig,
+    ConsoleConfig, DiskConfig, FsConfig, GpuConfig, LandlockConfig, MemoryConfig, PayloadConfig,
+    VmConfig, VsockConfig,
 };
 use net::net_setup;
 
@@ -130,6 +130,17 @@ pub fn vm_config(vm_dir: &Path) -> Result<VmConfig, String> {
             cid: 3,
             socket: vm_dir.join("vsock").into_os_string().into_string().unwrap(),
         },
+        landlock_enable: true,
+        landlock_rules: vec![
+            LandlockConfig {
+                path: "/sys/devices".to_owned(),
+                access: "rw",
+            },
+            LandlockConfig {
+                path: "/dev/vfio".to_owned(),
+                access: "rw",
+            },
+        ],
     })
 }
 

base-commit: 50f8db9cec022a60ea978bfdde0904a18718d161
-- 
2.51.0


             reply	other threads:[~2025-11-10 18:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 18:49 Alyssa Ross [this message]
2025-11-10 18:59 ` [PATCH] tools/start-vmm: enable Cloud Hypervisor landlock Demi Marie Obenour
2025-11-13 11:16 ` Alyssa Ross

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=20251110184907.346511-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).