Skip to content

Commit ded80b2

Browse files
committed
feat(vm): launch capability-free guest sandbox
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 1e01b8f commit ded80b2

39 files changed

Lines changed: 1867 additions & 3300 deletions

‎.github/workflows/release-vm-kernel.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Release VM Kernel
22

3-
# Build custom libkrunfw (kernel firmware) + libkrun (VMM) + gvproxy for all
3+
# Build custom libkrunfw (kernel firmware) + libkrun (VMM) for all
44
# supported openshell-driver-vm platforms. Artifacts are uploaded to the
55
# rolling "vm-runtime" GitHub Release and consumed by normal dev/tag release
66
# workflows when building the openshell-driver-vm binary.
@@ -237,7 +237,7 @@ jobs:
237237
238238
### Kernel Runtime Artifacts
239239
240-
Pre-built kernel runtime (libkrunfw + libkrun + gvproxy + umoci) for embedding
240+
Pre-built kernel runtime (libkrunfw + libkrun + umoci) for embedding
241241
into the `openshell-driver-vm` binary. These are rebuilt on demand when the
242242
kernel config or pinned dependency versions change.
243243

‎Cargo.lock‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎architecture/sandbox.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,12 @@ file and builds the `Proxy-Authorization: Basic` header; a credential that is
320320
empty, contains control characters, or is not in `user:pass` form is fatal on
321321
both sides.
322322

323-
The VM driver runs `openshell-supervisor` on the host. Corporate-proxy
324-
credentials, private CA keys, policy, and gateway credentials never enter the
325-
guest. The NIC-less guest reaches the host supervisor only through the
326-
authenticated vsock channel; the host supervisor performs DNS and upstream
327-
connections.
323+
The VM driver starts `openshell-supervisor` on the host and
324+
`openshell-sandbox` as capability-free guest PID 1. Corporate proxy arguments,
325+
credentials, private CA keys, policy, and gateway credentials stay host-side.
326+
Both libkrun and QEMU guests are NIC-less; intercepted workload connections
327+
cross the authenticated vsock channel. A gateway-host proxy is addressed as
328+
`host.openshell.internal`, which the host supervisor normalizes to `127.0.0.1`.
328329

329330
The Docker driver runs `openshell-supervisor` in a separate companion container.
330331
Its private named volume contains supervisor bootstrap and channel material.

‎crates/openshell-core/src/container_paths.rs‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,6 @@ pub const VM_GUEST_SANDBOX_TOKEN_PATH: &str = "/opt/openshell/auth/sandbox.jwt";
6666
pub const VM_GUEST_INIT_DROPIN_DIR: &str = "/opt/openshell/init.d";
6767
pub const VM_GUEST_INIT_DROPIN_MANIFEST: &str = "/opt/openshell/init.d.manifest";
6868

69-
/// Guest path for the corporate upstream-proxy credential in VM sandboxes.
70-
///
71-
/// The VM driver stages the `user:pass` credential here (mode `0600`,
72-
/// root-only) inside the per-sandbox overlay upperdir, and passes only this
73-
/// path on the supervisor's argv. A microVM has no bind mounts or container
74-
/// secrets, so this is the same delivery the per-sandbox JWT already uses.
75-
pub const VM_GUEST_UPSTREAM_PROXY_AUTH_PATH: &str = "/opt/openshell/auth/upstream-proxy";
76-
77-
/// Guest path for the corporate proxy CA bundle in VM sandboxes.
78-
///
79-
/// A CA certificate is not secret, so unlike the credential this is staged
80-
/// world-readable. The supervisor trusts it for the handshake with an
81-
/// `https://` proxy and for server certificates re-signed by a
82-
/// TLS-intercepting proxy.
83-
pub const VM_GUEST_PROXY_CA_PATH: &str = "/opt/openshell/tls/proxy-ca.pem";
84-
85-
/// Guest path for the driver-authored supervisor argument list in VM sandboxes.
86-
///
87-
/// Podman and Kubernetes build the supervisor's command line directly; the VM
88-
/// guest init script execs a fixed argv, so driver-owned arguments travel
89-
/// through this file instead. The driver writes it into the overlay upperdir
90-
/// on every launch — empty when it has no arguments to pass — so a sandbox
91-
/// image can neither forge entries nor shadow the driver's copy, and the
92-
/// guest appends exactly what it finds there and nothing else.
93-
pub const VM_GUEST_SUPERVISOR_ARGS_PATH: &str = "/opt/openshell/supervisor-args";
9469
pub const VM_UMOCI_PATH: &str = "/opt/openshell/bin/umoci";
9570
pub const VM_SANDBOX_OWNER_NORMALIZED_MARKER: &str = "/opt/openshell/.sandbox-owner-normalized";
9671

@@ -129,9 +104,6 @@ mod tests {
129104
VM_GUEST_SANDBOX_TOKEN_PATH,
130105
VM_GUEST_INIT_DROPIN_DIR,
131106
VM_GUEST_INIT_DROPIN_MANIFEST,
132-
VM_GUEST_UPSTREAM_PROXY_AUTH_PATH,
133-
VM_GUEST_PROXY_CA_PATH,
134-
VM_GUEST_SUPERVISOR_ARGS_PATH,
135107
VM_UMOCI_PATH,
136108
VM_SANDBOX_OWNER_NORMALIZED_MARKER,
137109
];

‎crates/openshell-driver-vm/Cargo.toml‎

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,83 @@ path = "src/lib.rs"
1717
[[bin]]
1818
name = "openshell-driver-vm"
1919
path = "src/main.rs"
20+
required-features = ["compute-driver"]
2021

2122
[dependencies]
2223
openshell-core = { path = "../openshell-core", default-features = false }
23-
openshell-otel = { path = "../openshell-otel" }
24-
openshell-policy = { path = "../openshell-policy" }
25-
openshell-driver-podman = { path = "../openshell-driver-podman" }
26-
openshell-vfio = { path = "../openshell-vfio" }
24+
openshell-isolation-interface = { path = "../openshell-isolation-interface" }
25+
openshell-otel = { path = "../openshell-otel", optional = true }
26+
openshell-policy = { path = "../openshell-policy", optional = true }
27+
openshell-driver-podman = { path = "../openshell-driver-podman", optional = true }
28+
openshell-vfio = { path = "../openshell-vfio", optional = true }
2729

28-
bollard = { version = "0.20", features = ["ssh"] }
30+
base64 = { workspace = true, optional = true }
31+
bollard = { version = "0.20", features = ["ssh"], optional = true }
2932
tokio = { workspace = true }
30-
tonic = { workspace = true, features = ["transport"] }
31-
tower-http = { workspace = true }
32-
http = { workspace = true }
33-
prost = { workspace = true }
34-
prost-types = { workspace = true }
35-
futures = { workspace = true }
36-
tokio-stream = { workspace = true, features = ["net"] }
37-
nix = { workspace = true }
38-
clap = { workspace = true }
39-
tracing = { workspace = true }
40-
tracing-subscriber = { workspace = true }
41-
opentelemetry = { workspace = true }
42-
opentelemetry_sdk = { workspace = true }
43-
tracing-opentelemetry = { workspace = true }
44-
miette = { workspace = true }
45-
url = { workspace = true }
33+
tonic = { workspace = true, features = ["transport"], optional = true }
34+
tower-http = { workspace = true, optional = true }
35+
http = { workspace = true, optional = true }
36+
prost = { workspace = true, optional = true }
37+
prost-types = { workspace = true, optional = true }
38+
futures = { workspace = true, optional = true }
39+
tokio-stream = { workspace = true, features = ["net"], optional = true }
40+
nix = { workspace = true, optional = true }
41+
clap = { workspace = true, optional = true }
42+
tracing = { workspace = true, optional = true }
43+
tracing-subscriber = { workspace = true, optional = true }
44+
opentelemetry = { workspace = true, optional = true }
45+
opentelemetry_sdk = { workspace = true, optional = true }
46+
tracing-opentelemetry = { workspace = true, optional = true }
47+
miette = { workspace = true, optional = true }
48+
rand = { workspace = true, optional = true }
49+
url = { workspace = true, optional = true }
4650
serde = { workspace = true }
4751
serde_json = { workspace = true }
48-
oci-client = "0.16"
52+
oci-client = { version = "0.16", optional = true }
4953
libc = "0.2"
50-
rustix = { workspace = true }
51-
libloading = "0.8"
52-
tar = "0.4"
53-
flate2 = "1"
54-
sha2 = "0.10"
55-
zstd = "0.13"
54+
rustix = { workspace = true, optional = true }
55+
libloading = { version = "0.8", optional = true }
56+
tar = { version = "0.4", optional = true }
57+
flate2 = { version = "1", optional = true }
58+
sha2 = { version = "0.10", optional = true }
59+
zstd = { version = "0.13", optional = true }
5660

5761
[features]
58-
default = ["telemetry"]
62+
default = ["compute-driver", "telemetry"]
63+
## Build the standalone compute driver and its host runtime implementation.
64+
compute-driver = [
65+
"dep:base64",
66+
"dep:bollard",
67+
"dep:clap",
68+
"dep:flate2",
69+
"dep:futures",
70+
"dep:http",
71+
"dep:libloading",
72+
"dep:miette",
73+
"dep:nix",
74+
"dep:oci-client",
75+
"dep:openshell-otel",
76+
"dep:openshell-policy",
77+
"dep:openshell-driver-podman",
78+
"dep:openshell-vfio",
79+
"dep:opentelemetry",
80+
"dep:opentelemetry_sdk",
81+
"dep:polling",
82+
"dep:prost",
83+
"dep:prost-types",
84+
"dep:rand",
85+
"dep:rustix",
86+
"dep:sha2",
87+
"dep:tar",
88+
"dep:tokio-stream",
89+
"dep:tonic",
90+
"dep:tower-http",
91+
"dep:tracing",
92+
"dep:tracing-opentelemetry",
93+
"dep:tracing-subscriber",
94+
"dep:url",
95+
"dep:zstd",
96+
]
5997
## Compile in telemetry support (forwards to openshell-core/telemetry). On by
6098
## default; build with `--no-default-features` for a telemetry-free VM driver
6199
## that reports telemetry disabled to the sandboxes it launches.
@@ -68,7 +106,7 @@ telemetry = ["openshell-core/telemetry"]
68106
## enabling it alongside `telemetry` is a compile error rather than a silent
69107
## telemetry-on build. Kept in sync with `default` by
70108
## `rust:verify:defaults-without-telemetry`.
71-
defaults-without-telemetry = []
109+
defaults-without-telemetry = ["compute-driver"]
72110

73111
[dev-dependencies]
74112
openshell-otel-test-support = { path = "../openshell-otel-test-support" }
@@ -82,7 +120,7 @@ opentelemetry_sdk = { workspace = true, features = ["testing"] }
82120
# nix::sys::prctl::set_pdeathsig there keeps the Linux path a single
83121
# syscall with no helper thread.
84122
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", target_os = "dragonfly"))'.dependencies]
85-
polling = "3.11"
123+
polling = { version = "3.11", optional = true }
86124

87125
[lints]
88126
workspace = true

0 commit comments

Comments
 (0)