Skip to content

Commit 069ae6b

Browse files
authored
fix(vm): scope GPU filesystem enrichment to assigned workloads (NVIDIA#3580)
* fix(vm): scope GPU filesystem enrichment to assigned workloads Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(supervisor): clarify proxy baseline enrichment Signed-off-by: Drew Newberry <anewberry@nvidia.com> --------- Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent d02ebe2 commit 069ae6b

7 files changed

Lines changed: 80 additions & 257 deletions

File tree

‎architecture/sandbox.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ OpenShell uses overlapping controls rather than a single sandbox primitive:
135135
| Outer network fence | The component that owns network enforcement prevents any missed or unsupported kernel path from escaping. Current examples are Docker `network_mode=none`, a NIC-less VM, and Kubernetes NetworkPolicy. |
136136
| Policy proxy | Evaluates destination, binary identity, TLS/L7 rules, SSRF checks, and inference interception. |
137137

138-
The supervisor may enrich baseline filesystem allowances for runtime-required
139-
paths, such as proxy support files or GPU device paths when a GPU is present.
138+
The supervisor may enrich baseline filesystem allowances for proxy support
139+
files. GPU allowances are added by the workload-side sandbox only when the
140+
immutable driver resource claims request a GPU and GPU devices are visible
141+
inside the workload. Host supervisor device discovery must not influence these
142+
allowances; a CPU-only VM preserves read-only `/proc` even on a GPU host.
140143
These internal allowances must stay sandbox-scoped and avoid exposing host
141144
secrets. For example, MXC governed egress grants the generated public CA bundle
142145
while the ephemeral CA private key remains in the host proxy's memory.

‎crates/openshell-driver-vm/src/driver.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,7 @@ impl VmDriver {
15571557
agent_uid: sandbox_owner_state.uid,
15581558
agent_gid: sandbox_owner_state.gid,
15591559
child_env: merged_environment(&sandbox),
1560+
gpu_requested: is_gpu,
15601561
}
15611562
.provision()
15621563
.map_err(|error| Status::failed_precondition(error.to_string()))?;

‎crates/openshell-driver-vm/src/isolation/mod.rs‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use openshell_isolation_interface::contract::{
1212
BackendError, OuterFenceGuarantee, OuterFenceGuarantees, ResolvedWorkloadIdentity,
1313
};
14+
use openshell_sandbox_backend::GPU_RESOURCE_CLAIM;
1415
use openshell_sandbox_backend::boundary_protocol::{
1516
BoundaryConfig, BoundaryListener, GatewayVerificationKey, SandboxRuntimeDescriptor,
1617
SandboxTlsClientConfig, SandboxTlsServerConfig, SandboxTransport,
@@ -70,6 +71,7 @@ pub struct VmBoundarySpec {
7071
pub agent_uid: u32,
7172
pub agent_gid: u32,
7273
pub child_env: HashMap<String, String>,
74+
pub gpu_requested: bool,
7375
}
7476

7577
/// The protected guest config and matching host descriptor for one VM.
@@ -89,10 +91,13 @@ impl VmBoundarySpec {
8991
"vm-config".to_string(),
9092
self.image_identity.clone(),
9193
)?;
92-
let resource_claims = BTreeMap::from([
94+
let mut resource_claims = BTreeMap::from([
9395
("vm.generation".to_string(), self.generation.clone()),
9496
("vm.image_identity".to_string(), self.image_identity),
9597
]);
98+
if self.gpu_requested {
99+
resource_claims.insert(GPU_RESOURCE_CLAIM.to_string(), "true".to_string());
100+
}
96101
let outer_fence = VmOuterFenceEvidence {
97102
generation: &self.generation,
98103
network_device_count: 0,
@@ -165,6 +170,12 @@ mod tests {
165170

166171
#[test]
167172
fn provisioning_binds_identical_resource_claims() {
173+
for gpu_requested in [false, true] {
174+
assert_provisioning_claims(gpu_requested);
175+
}
176+
}
177+
178+
fn assert_provisioning_claims(gpu_requested: bool) {
168179
let session_id = openshell_core::SandboxSessionId::new();
169180
let material = generate_sandbox_tls_material(session_id).unwrap();
170181
let provisioned = VmBoundarySpec {
@@ -195,6 +206,7 @@ mod tests {
195206
agent_uid: 1000,
196207
agent_gid: 1000,
197208
child_env: HashMap::new(),
209+
gpu_requested,
198210
}
199211
.provision()
200212
.unwrap();
@@ -203,6 +215,14 @@ mod tests {
203215
provisioned.boundary_config.resource_claims,
204216
provisioned.runtime_descriptor.resource_claims
205217
);
218+
assert_eq!(
219+
provisioned
220+
.runtime_descriptor
221+
.resource_claims
222+
.get(GPU_RESOURCE_CLAIM)
223+
.map(String::as_str),
224+
gpu_requested.then_some("true")
225+
);
206226
assert_eq!(
207227
provisioned.runtime_descriptor.resource_claims["vm.generation"],
208228
"generation-1"

‎crates/openshell-sandbox/src/boundary_server.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ mod linux {
8282
const MAX_REPLAY_LEDGER_ENTRIES: usize = 4096;
8383
const MAX_RETAINED_EXEC_PROCESSES: usize = 64;
8484

85+
// NVML may traverse the persistenced socket directory during initialization;
86+
// WSL2 supplies GPU libraries under /usr/lib/wsl and the /dev/dxg device.
8587
const GPU_BASELINE_READ_ONLY: &[&str] = &["/run/nvidia-persistenced", "/usr/lib/wsl"];
88+
// CUDA opens device nodes read-write and writes thread names through
89+
// /proc/<pid>/task/<tid>/comm during cuInit(). A /proc/self rule would bind
90+
// to the launcher's inodes, not those of its workload children.
8691
const GPU_BASELINE_READ_WRITE: &[&str] = &[
8792
"/dev/nvidiactl",
8893
"/dev/nvidia-uvm",
@@ -97,8 +102,8 @@ mod linux {
97102
}
98103

99104
/// Add the filesystem paths required by GPU devices visible inside the
100-
/// workload container. The companion supervisor intentionally has no GPU
101-
/// devices, so it cannot discover these paths on the sandbox's behalf.
105+
/// workload. The supervisor's device namespace can differ from the
106+
/// workload's, so discovery must happen here, gated by the resource claim.
102107
fn enrich_gpu_filesystem_paths(
103108
policy: &mut openshell_core::policy::SandboxPolicy,
104109
gpu_requested: bool,

0 commit comments

Comments
 (0)