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

@ -13,8 +13,9 @@ use lazaret_core::records::{
HostProcessOwnershipSlot, ProcessOwnershipCommitAck, StagedProcessOwnership,
};
use lazaret_linux::process::{
ChildStandardIo, ProcessOwnershipContext, TargetCommand, append_parent_identity, child_broker,
current_process_identity, dispatch_private_process_role, verify_direct_child_pidfd,
AcknowledgedChildAcquisition, ChildStandardIo, ProcessOwnershipContext, TargetCommand,
append_parent_identity, child_broker, current_process_identity, dispatch_private_process_role,
verify_direct_child_pidfd,
};
use rustix::pipe::{PipeFlags, pipe_with};
use rustix::process::{PidfdFlags, pidfd_open};
@ -45,6 +46,7 @@ fn exit(result: std::io::Result<()>) -> ExitCode {
fn run_all() -> std::io::Result<()> {
successful_acquisition()?;
acknowledged_transition_precedes_exact_wrapper_release()?;
failed_acknowledged_transition_refuses_exact_wrapper_release()?;
lifetime_pipe_descriptor_contract()?;
failed_stages_and_acknowledgments()?;
production_wrapper_refuses_former_harness_path()?;
@ -54,6 +56,29 @@ fn run_all() -> std::io::Result<()> {
concurrent_acquisitions_serialize()
}
#[allow(clippy::disallowed_methods, clippy::disallowed_types)]
fn failed_acknowledged_transition_refuses_exact_wrapper_release() -> std::io::Result<()> {
let target_marker = marker("failed-transition-target");
let target = TargetCommand::new("/usr/bin/touch").argument(&target_marker);
let result = child_broker().acquire_with_stdio_after_ack(
AcknowledgedChildAcquisition {
expected_parent: current_process_identity()?,
ownership: context(),
target: &target,
standard_io: ChildStandardIo::inherit(),
},
|_| Ok(()),
|staged| Ok(ProcessOwnershipCommitAck::v1(staged)),
|| Err(std::io::Error::other("handoff authority changed")),
);
if result.is_ok() || target_marker.exists() {
return Err(std::io::Error::other(
"failed transition released the exact wrapper",
));
}
Ok(())
}
#[allow(clippy::disallowed_methods, clippy::disallowed_types)]
fn acknowledged_transition_precedes_exact_wrapper_release() -> std::io::Result<()> {
let target_marker = marker("transition-target");
@ -62,10 +87,12 @@ fn acknowledged_transition_precedes_exact_wrapper_release() -> std::io::Result<(
let acknowledged = std::cell::Cell::new(false);
let target = TargetCommand::new("/usr/bin/touch").argument(&target_marker);
let process = child_broker().acquire_with_stdio_after_ack(
parent,
context(),
&target,
ChildStandardIo::inherit(),
AcknowledgedChildAcquisition {
expected_parent: parent,
ownership: context(),
target: &target,
standard_io: ChildStandardIo::inherit(),
},
|ownership| {
staged.set(Some(ownership));
Ok(())