Bind sandbox handoff authority and restore verifier gates

This commit is contained in:
ms2k 2026-07-16 15:20:13 +09:00
commit 49d5def1a9

View file

@ -163,6 +163,13 @@ pub struct ProcessOwnershipContext {
pub slot: HostProcessOwnershipSlot,
}
pub struct AcknowledgedChildAcquisition<'target> {
pub expected_parent: PidfsProcessIdentityV1,
pub ownership: ProcessOwnershipContext,
pub target: &'target TargetCommand,
pub standard_io: ChildStandardIo,
}
#[derive(Debug)]
pub struct RetainedProcess {
pidfd: OwnedFd,
@ -366,10 +373,12 @@ impl ChildBroker {
Acknowledge: FnOnce(StagedProcessOwnership) -> io::Result<ProcessOwnershipCommitAck>,
{
self.acquire_with_stdio_after_ack(
expected_parent,
ownership,
target,
standard_io,
AcknowledgedChildAcquisition {
expected_parent,
ownership,
target,
standard_io,
},
stage,
acknowledge,
|| Ok(()),
@ -385,10 +394,7 @@ impl ChildBroker {
#[allow(clippy::disallowed_methods, clippy::disallowed_types)]
pub fn acquire_with_stdio_after_ack<Stage, Acknowledge, Transition>(
&self,
expected_parent: PidfsProcessIdentityV1,
ownership: ProcessOwnershipContext,
target: &TargetCommand,
mut standard_io: ChildStandardIo,
acquisition: AcknowledgedChildAcquisition<'_>,
stage: Stage,
acknowledge: Acknowledge,
transition: Transition,
@ -402,14 +408,18 @@ impl ChildBroker {
.exclusion
.lock()
.map_err(|_| io::Error::other("child broker lock poisoned"))?;
require_parent_edge_standard_io(target.parent_edge(), standard_io.policy())?;
require_parent_edge_standard_io(
acquisition.target.parent_edge(),
acquisition.standard_io.policy(),
)?;
require_default_sigchld()?;
require_reapable_sigchld()?;
let (release, wait) = launch_barrier()?;
let mut command = private_role_command(WRAPPER_ROLE);
append_parent_identity(&mut command, expected_parent);
target.append_to(&mut command);
append_parent_identity(&mut command, acquisition.expected_parent);
acquisition.target.append_to(&mut command);
command.stdin(wait.into_stdio());
let mut standard_io = acquisition.standard_io;
if let Some(stdout) = standard_io.stdout.take() {
command.stdout(stdout);
}
@ -424,10 +434,10 @@ impl ChildBroker {
Err(error) => return fail_before_pidfd(release, &mut child, error),
};
let staged = StagedProcessOwnership::v1(
ownership.domain_id,
ownership.generation_id,
ownership.coordinator_id,
ownership.slot,
acquisition.ownership.domain_id,
acquisition.ownership.generation_id,
acquisition.ownership.coordinator_id,
acquisition.ownership.slot,
process.identity,
);
if let Err(error) = stage(staged) {