Skip to content

Commit 5102cb9

Browse files
authored
fix(sandbox): restore GPU procfs baseline (#1522)
Signed-off-by: Evan Lezar <[email protected]>
1 parent 19be568 commit 5102cb9

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎architecture/security-policy.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ For the field-by-field YAML reference, use
2121
Filesystem and process policy are startup-time controls. Network policy is
2222
dynamic and can be hot-reloaded when the new policy validates successfully.
2323

24+
Before applying Landlock, the supervisor enriches baseline filesystem paths that
25+
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`.
30+
2431
## Network Decisions
2532

2633
Ordinary network traffic follows this order:

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ where
16181618
}
16191619
}
16201620
for path in rw {
1621-
if fs.read_only.iter().any(|p| p == path) || fs.read_write.iter().any(|p| p == path) {
1621+
if fs.read_write.iter().any(|p| p == path) {
16221622
continue;
16231623
}
16241624
if !path_exists(path) {
@@ -1628,6 +1628,18 @@ where
16281628
);
16291629
continue;
16301630
}
1631+
if fs.read_only.iter().any(|p| p == path) {
1632+
if path == "/proc" {
1633+
info!(
1634+
path,
1635+
"Promoting /proc from read-only to read-write for GPU runtime compatibility"
1636+
);
1637+
fs.read_only.retain(|p| p != path);
1638+
fs.read_write.push(path.clone());
1639+
modified = true;
1640+
}
1641+
continue;
1642+
}
16311643
fs.read_write.push(path.clone());
16321644
modified = true;
16331645
}
@@ -1845,7 +1857,7 @@ mod baseline_tests {
18451857
}
18461858

18471859
#[test]
1848-
fn proto_gpu_enrichment_adds_devices_without_network_policy() {
1860+
fn proto_gpu_enrichment_promotes_proc_without_network_policy() {
18491861
let mut policy = openshell_policy::restrictive_default_policy();
18501862
assert!(
18511863
policy.network_policies.is_empty(),
@@ -1867,6 +1879,14 @@ mod baseline_tests {
18671879
filesystem.read_write.contains(&"/dev/nvidia0".to_string()),
18681880
"GPU enrichment should add enumerated device nodes without network policies"
18691881
);
1882+
assert!(
1883+
!filesystem.read_only.contains(&"/proc".to_string()),
1884+
"GPU enrichment should remove /proc from read_only"
1885+
);
1886+
assert!(
1887+
filesystem.read_write.contains(&"/proc".to_string()),
1888+
"GPU enrichment should promote /proc to read_write"
1889+
);
18701890
}
18711891

18721892
#[test]

‎docs/sandboxes/policies.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Raw streams are connection-scoped and outside L7 live-reload guarantees. This in
6262

6363
When a sandbox runs in proxy mode (the default), OpenShell automatically adds baseline filesystem paths required for the sandbox child process to function: `/usr`, `/lib`, `/etc`, `/var/log` (read-only) and `/sandbox`, `/tmp` (read-write). Paths like `/app` are included in the baseline set but are only added if they exist in the container image.
6464

65+
For GPU sandboxes, OpenShell also adds existing GPU device nodes as read-write paths. CUDA workloads require write access to procfs for thread metadata, so GPU baseline enrichment moves `/proc` from read-only to read-write when GPU devices are present.
66+
6567
This filtering prevents a missing baseline path from degrading Landlock enforcement. Without it, a single missing path could cause the entire Landlock ruleset to fail, leaving the sandbox with no filesystem restrictions at all.
6668

6769
User-specified paths in your policy YAML are not pre-filtered. If you list a path that does not exist:

0 commit comments

Comments
 (0)