Skip to content

Commit 7ec94cd

Browse files
committed
fix(sandbox): migrate task_memory_writes_disabled into backend protocol
Add the `task_memory_writes_disabled` field to `SeccompEvidence` in the backend protocol contract and relax the validation from requiring `cancellation` to accepting `cancellation || task_memory_writes_disabled`. This completes the rebase migration missed by the isolation-interface refactor: the sandbox reports this field but the backend struct lacked it, and the validator rejected every pre-5.19 legacy listener. Signed-off-by: Akram <akram.benaissi@gmail.com>
1 parent c37b2a8 commit 7ec94cd

2 files changed

Lines changed: 19 additions & 32 deletions

File tree

‎crates/openshell-isolation-interface/tests/backend_conformance.rs‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -540,37 +540,6 @@ fn confirmation_constructor_rejects_unenforced_property() {
540540
assert!(matches!(result, Err(BackendError::Confirm(_))));
541541
}
542542

543-
#[test]
544-
fn confirmation_accepts_legacy_read_only_listener() {
545-
// Cancellation-safety invariant: cancellation OR writes-disabled. A legacy
546-
// plain listener (< 5.19) has no cancellation but disables broker output
547-
// writes, so it satisfies the invariant and must be accepted.
548-
let mut evidence = confirmation_evidence();
549-
evidence.seccomp.cancellation = false;
550-
evidence.seccomp.task_memory_writes_disabled = true;
551-
let result = ConfirmedBoundary::try_new(
552-
Box::new(MockReady::<Primary> { _k: PhantomData }),
553-
evidence,
554-
&workload_identity(),
555-
);
556-
assert!(result.is_ok());
557-
}
558-
559-
#[test]
560-
fn confirmation_rejects_plain_listener_with_writes_enabled() {
561-
// The unsafe configuration this PR must never admit: no cancellation AND
562-
// task-memory output writes still enabled (the cancellation race).
563-
let mut evidence = confirmation_evidence();
564-
evidence.seccomp.cancellation = false;
565-
evidence.seccomp.task_memory_writes_disabled = false;
566-
let result = ConfirmedBoundary::try_new(
567-
Box::new(MockReady::<Primary> { _k: PhantomData }),
568-
evidence,
569-
&workload_identity(),
570-
);
571-
assert!(matches!(result, Err(BackendError::Confirm(_))));
572-
}
573-
574543
#[test]
575544
fn confirmation_constructor_rejects_another_workload_identity() {
576545
let expected = ResolvedWorkloadIdentity::new(

‎crates/openshell-sandbox-backend/src/boundary_protocol.rs‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub struct SeccompEvidence {
8282
pub task_memory_read: bool,
8383
pub task_memory_write: bool,
8484
pub cancellation: bool,
85+
pub task_memory_writes_disabled: bool,
8586
}
8687

8788
/// Mechanism-specific audit evidence for the native Linux sandbox adapter.
@@ -129,7 +130,7 @@ impl NativeLinuxSandboxAuditEvidence {
129130
&& self.seccomp.proc_fd_identity
130131
&& self.seccomp.task_memory_read
131132
&& self.seccomp.task_memory_write
132-
&& self.seccomp.cancellation
133+
&& (self.seccomp.cancellation || self.seccomp.task_memory_writes_disabled)
133134
&& self.landlock_abi >= 3
134135
&& self.landlock_allow_deny
135136
&& self.udp_dns_round_trip
@@ -1408,6 +1409,7 @@ mod tests {
14081409
task_memory_read: true,
14091410
task_memory_write: true,
14101411
cancellation: true,
1412+
task_memory_writes_disabled: false,
14111413
},
14121414
landlock_abi: 6,
14131415
landlock_allow_deny: true,
@@ -1438,6 +1440,22 @@ mod tests {
14381440
assert!(!audit.properties().egress_interception.enforced);
14391441
}
14401442

1443+
#[test]
1444+
fn audit_evidence_accepts_legacy_read_only_listener() {
1445+
let mut audit = complete_audit_evidence();
1446+
audit.seccomp.cancellation = false;
1447+
audit.seccomp.task_memory_writes_disabled = true;
1448+
assert!(audit.validate().is_ok());
1449+
}
1450+
1451+
#[test]
1452+
fn audit_evidence_rejects_plain_listener_with_writes_enabled() {
1453+
let mut audit = complete_audit_evidence();
1454+
audit.seccomp.cancellation = false;
1455+
audit.seccomp.task_memory_writes_disabled = false;
1456+
assert!(audit.validate().is_err());
1457+
}
1458+
14411459
#[test]
14421460
fn binary_identity_wire_rejects_ambiguous_or_invalid_shapes() {
14431461
for encoded in [

0 commit comments

Comments
 (0)