1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! `InheritedFds::None` lowering for the Linux backend (proof-spine §5/S5), split out
//! of `backend_impl.rs` to hold it under the non-overridable file-size cap.
//!
//! THE LOWERING (the seam S4 set for `EnvPolicy::Exact`): the admitted [`FdPolicy`]
//! DRIVES the launcher's fd-scrub close-list. For [`FdPolicy::None`] the workload
//! inherits ONLY the launcher's own protocol/stdio fds plus the descriptor-table
//! authority slots (exe + confinement roots) — the launcher's child-side scrub closes
//! EVERY other inherited fd before `fexecve` (the allowlist complement). So the admitted
//! `None` policy is realized by the descriptor-table-driven scrub already built in
//! `plan_build` + `launcher::imp`; this module is the CONTRACT-LEVEL gate that confirms
//! the admitted policy is one the lowering actually realizes, and FAILS CLOSED otherwise
//! (the workload never runs under an unrealized fd policy).
//!
//! `FdPolicy::Only(..)` is OUT OF SCOPE (S5) — it is absent from the ceiling so it never
//! admits, but defense-in-depth this gate ALSO refuses it here: were it ever to reach
//! `execute()` (a future ceiling change without a lowering), the workload must NOT run
//! with the scrub silently realizing the wrong policy (which would leak no fd, but would
//! ALSO not honor the `Only` allowlist — an unrealized guarantee). SAFE std; the OS work
//! (the scrub itself) is the launcher's.
use LinuxBackend;
use crate;
use crate;
use crateObservedFact;
/// LOWER the plan's admitted [`Capability::InheritedFds`] policy onto the launcher
/// scrub. The scrub close-list itself is built (descriptor-table-driven) in
/// `plan_build`/`launcher::imp`; this is the contract gate that confirms the admitted
/// policy is REALIZED by that scrub. On a policy the lowering does not realize it
/// returns `Err(observed)` with an `inherited_fds_lowering_failed` fact appended, so the
/// caller FAILS CLOSED — the workload never runs.
///
/// `_backend` is unused today (the scrub needs no host resolver, unlike the env lease
/// resolver) but kept in the signature so the seam matches `lower_environment` and a
/// future `Only` realization can consult host state.
pub
/// The admitted [`FdPolicy`] to realize: the admitted `InheritedFds` capability's
/// policy, or [`FdPolicy::None`] when the spec declared no `InheritedFds` capability
/// (⇒ the default is no inherited fds — nothing survives the scrub but the declared
/// authority + stdio). The plan was admitted against our ceiling, so any admitted
/// `InheritedFds` capability whose key is `InheritedFdsNone` is the `None` variant.