Skip to content

Commit b6b3ce4

Browse files
committed
feat(sandbox): derive policy from CDI context
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 722e6d9 commit b6b3ce4

8 files changed

Lines changed: 1101 additions & 280 deletions

File tree

architecture/security-policy.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@ dynamic and can be hot-reloaded when the new policy validates successfully.
2323

2424
Before applying Landlock, the supervisor enriches baseline filesystem paths that
2525
the runtime needs. Missing baseline paths are skipped so one absent runtime path
26-
does not weaken the whole ruleset. When GPU devices are present, GPU baseline
27-
enrichment adds existing GPU device nodes as read-write paths and promotes
28-
`/proc` to read-write because CUDA workloads write thread metadata under
29-
`/proc/<pid>/task/<tid>/comm`.
26+
does not weaken the whole ruleset. When GPU devices are present without a CDI
27+
context, GPU baseline enrichment adds existing GPU device nodes as read-write
28+
paths. GPU sandboxes with CDI context use CDI-derived paths instead of the
29+
hard-coded GPU baseline. Both paths promote `/proc` to read-write because CUDA
30+
workloads write thread metadata under `/proc/<pid>/task/<tid>/comm`.
31+
32+
GPU/CDI sandboxes can also carry a supervisor-only CDI context from the compute
33+
driver. The supervisor resolves selected CDI IDs from mounted CDI specs and
34+
adds derived device nodes, library mount destinations, and supplemental GIDs
35+
before agent exec. CDI host paths are ignored for policy. Derived mount
36+
destinations default to read-only; writable CDI single-file mounts require an
37+
exact `filesystem_policy.read_write` opt-in, and writable CDI directory mounts
38+
fail closed. CDI resolution errors are security-relevant startup failures and
39+
emit OCSF findings.
3040

3141
Landlock rules are tailored to the inode type reported by the already-opened
3242
path descriptor. Directories retain the requested directory and file rights;

crates/openshell-core/src/cdi.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ use serde::{Deserialize, Serialize};
99

1010
pub const CDI_CONTEXT_VERSION: u32 = 1;
1111

12+
/// Absolute supervisor path for the CDI context file mounted by a compute driver.
13+
pub const CDI_CONTEXT_PATH: &str = "/run/openshell/supervisor/cdi-context.json";
14+
15+
/// Base supervisor path under which compute drivers mount CDI specification directories.
16+
pub const CDI_SPEC_DIR_BASE: &str = "/run/openshell/supervisor/cdi-specs";
17+
1218
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1319
pub struct CdiContext {
1420
pub version: u32,

crates/openshell-core/src/policy.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ pub struct ProcessPolicy {
8383

8484
/// Group name to run the sandboxed process as.
8585
pub run_as_group: Option<String>,
86+
87+
/// Linux supplemental groups to apply before dropping privileges.
88+
///
89+
/// Runtime-specific inputs can use different terminology; CDI
90+
/// `additionalGids` are converted into this process-level representation.
91+
pub supplemental_groups: Vec<u32>,
8692
}
8793

8894
#[derive(Debug, Clone, Default)]
@@ -162,6 +168,7 @@ impl From<ProtoProcessPolicy> for ProcessPolicy {
162168
} else {
163169
Some(proto.run_as_group)
164170
},
171+
supplemental_groups: Vec::new(),
165172
}
166173
}
167174
}

0 commit comments

Comments
 (0)