mirror of
https://github.com/openai/codex.git
synced 2026-11-20 23:08:21 +00:00
Support FD mounts with older system Bubblewrap versions (#39404)
## Why System Bubblewrap installations that lack `--ro-bind-fd` cannot directly create the descriptor-backed read-only mounts used by the Linux sandbox. ## What changed - Detect `--ro-bind-fd` support when probing system Bubblewrap. - On older versions, translate descriptor-backed mounts to `/proc/self/fd` read-only binds and pass their descriptors and destinations to the trusted inner sandbox stage for verification. - Reject malformed, duplicate, mismatched, or symlink-substituted mounts, and close inherited descriptors before running sandboxed code. ## Testing Added unit coverage for capability detection, legacy argument translation, invalid mount rejection, inode verification, and descriptor closure. GitOrigin-RevId: dfc0a457b572cdd9aed093fb5abf57360e9724a2
This commit is contained in:
1 parent
956f590ad5
commit
6cc2ba8a95
5 files changed
+448
No files matched your search
@@ -131,6 +131,10 @@ pub struct LandlockCommand {
|
||||
#[arg(long = "proxy-route-spec", hide = true)]
|
||||
pub proxy_route_spec: Option<String>,
|
||||
|
||||
/// Inherited fallback mounts that must be authenticated before sandboxed code runs.
|
||||
#[arg(long = "verify-fd-mount", hide = true)]
|
||||
pub verify_fd_mounts: Vec<String>,
|
||||
|
||||
/// When set, skip mounting a fresh `/proc` even though PID isolation is
|
||||
/// still enabled. This is primarily intended for restrictive container
|
||||
/// environments that deny `--proc /proc`.
|
||||
@@ -158,6 +162,7 @@ pub fn run_main() -> ! {
|
||||
apply_seccomp_then_exec,
|
||||
allow_network_for_proxy,
|
||||
proxy_route_spec,
|
||||
verify_fd_mounts,
|
||||
no_proc,
|
||||
command,
|
||||
} = LandlockCommand::parse();
|
||||
@@ -165,6 +170,9 @@ pub fn run_main() -> ! {
|
||||
if command.is_empty() {
|
||||
panic!("No command specified to execute.");
|
||||
}
|
||||
if !apply_seccomp_then_exec && !verify_fd_mounts.is_empty() {
|
||||
panic!("--verify-fd-mount is only supported in the inner sandbox stage");
|
||||
}
|
||||
ensure_inner_stage_mode_is_valid(apply_seccomp_then_exec, use_legacy_landlock);
|
||||
let EffectivePermissions {
|
||||
permission_profile,
|
||||
@@ -181,6 +189,10 @@ pub fn run_main() -> ! {
|
||||
// Inner stage: apply seccomp/no_new_privs after bubblewrap has already
|
||||
// established the filesystem view.
|
||||
if apply_seccomp_then_exec {
|
||||
if let Err(err) = crate::fd_mount::verify_fd_mounts(&verify_fd_mounts) {
|
||||
panic!("failed to verify descriptor-backed bubblewrap mount: {err}");
|
||||
}
|
||||
|
||||
let mut capability_header = [LINUX_CAPABILITY_VERSION_3, 0];
|
||||
let mut capability_sets = [[0_u32; 3]; 2];
|
||||
// SAFETY: capability ABI version 3 uses a [version, pid] header and
|
||||
|
||||
Reference in new issue
Block a user