Skip to content

Commit 956ccb5

Browse files
committed
fix(supervisor): tolerate non-empty bounding set when CAP_SETPCAP is unavailable
On rootless Podman with AppArmor unprivileged user namespace restrictions (Ubuntu 24.04 default), CAP_SETPCAP is granted by Podman but blocked at the kernel level by AppArmor. This causes drop_capability_bounding_set() to fail with EPERM while the bounding set is non-empty — a case that was unhandled, crashing sandbox creation. Add a match arm that logs a warning and continues when EPERM is returned with a non-empty bounding set. The child process is still confined by seccomp and Landlock. Fixes: NVIDIA#2069 Assisted-by: Claude Signed-off-by: Wayne Sun <[email protected]>
1 parent 5477e2f commit 956ccb5

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

‎crates/openshell-supervisor-process/src/process.rs‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::process::Stdio;
2626
#[cfg(target_os = "linux")]
2727
use std::sync::OnceLock;
2828
use tokio::process::{Child, Command};
29-
use tracing::debug;
29+
use tracing::{debug, warn};
3030

3131
const SUPERVISOR_ONLY_ENV_VARS: &[&str] = &[
3232
openshell_core::sandbox_env::SANDBOX_TOKEN,
@@ -189,6 +189,14 @@ fn validate_capability_bounding_set_clear(
189189
"Failed to clear unknown child capability bounding set entries: {unknown_err}"
190190
)),
191191
},
192+
Err(err) if err.code() == libc::EPERM => {
193+
warn!(
194+
?remaining,
195+
"CAP_SETPCAP is unavailable and the child capability bounding set is non-empty; \
196+
the child process relies on seccomp and Landlock for confinement"
197+
);
198+
Ok(())
199+
}
192200
Err(err) => Err(miette::miette!(
193201
"Failed to clear child capability bounding set: {err}"
194202
)),
@@ -1150,22 +1158,17 @@ mod tests {
11501158

11511159
#[test]
11521160
#[cfg(target_os = "linux")]
1153-
fn capability_bounding_set_clear_rejects_nonempty_eperm() {
1161+
fn capability_bounding_set_clear_tolerates_nonempty_eperm() {
11541162
let mut remaining = capctl::caps::CapSet::empty();
11551163
remaining.add(capctl::caps::Cap::CHOWN);
11561164

1157-
let result = validate_capability_bounding_set_clear(
1158-
Err(capctl::Error::from_code(libc::EPERM)),
1159-
remaining,
1160-
|| panic!("unknown capabilities should not be checked when known caps remain"),
1161-
);
1162-
1163-
assert!(result.is_err());
11641165
assert!(
1165-
result
1166-
.unwrap_err()
1167-
.to_string()
1168-
.contains("Failed to clear child capability bounding set")
1166+
validate_capability_bounding_set_clear(
1167+
Err(capctl::Error::from_code(libc::EPERM)),
1168+
remaining,
1169+
|| panic!("unknown capabilities should not be checked when known caps remain"),
1170+
)
1171+
.is_ok()
11691172
);
11701173
}
11711174

0 commit comments

Comments
 (0)