A launch’s report is the trampoline’s alone
Nothing but the trampoline can write a launch’s report, and nothing the
program runs can hold it. The report is what a confined launch’s trampoline
says of its program (core/src/process/report.rs; the socket is made in
issue, core/src/authority/sandbox/launch.rs). The parent acts on it: a
record is believed. This page is the one home of the records and of who may
write them.
- It is a socketpair, never a pipe. A same-uid process can reopen a pipe’s
writer through
/proc/<pid>/fdand forge a record; it cannot reopen a socket. The trampoline checks that its descriptor is a socket before it speaks (Witness::new). - The records are
refused(message),unstarted(errno),startedandended(status), a tag byte and its payload, each composed whole and sent by onewrite_all, each at most once and in that order.refusedcarries a message cut tou16::MAXbytes and its length, so the reader reads exactly what the record states; the trampoline is the only writer, so nothing can interleave with it. A cut or unknown record is an error, never an end.refused: the warrant could not be received or its confinement entered, or ral’s own step failed before the program began; nothing ran.unstarted: the program’s ownexecvefailed.startedandended(Linux): the program runs, and the program ended so.
unstartedis the program’s ownexecveand nothing else. On Linux the trampoline’s child says whether it began (die_withfor a file; signal defaults, mask anddie_withfor a bundled tool) on a close-on-exec pipe beforeexecveor the tool’s entry, and the supervisor saysstartedonly after that word. A failedforkor spawn, or a child that cannot begin, isrefused, and a file’s spawn error isunstartedonly when its child said it began. An error the OS did not raise (Witness::unstartedof anio::Errorwith no errno) isrefusedtoo. So a failure of ral’s own never reads asnot-runnable, nor as the program havingexited 126.- The trampoline’s end is typed by what it may still say.
Witnesscan sayrefusedorunstarted;startedconsumes it and yieldsRunning, whoseendedis the only way to writeended(Linux), so a record out of order cannot be written. - The writer is lent by number and closed by the parent at the fork. The
parent’s copy of the writer (
Report::new, kept byHandoff::keep) stays open past the spawn because the onepre_execofHandoff::installclears close-on-exec on that number.forkdrops the command immediately after spawning, releasing child-only descriptors.Launcher::heardthen callsReport::forked, forLaunch::bornandspawn_detachedalike. A launch’s oneLauncherholds the report:Launch::trampolinedfixes a direct trampoline’s, andEnvelopedLaunchits envelope’s mandatory one. No mutable configuration can add another. EOF then means every copy in the child’s tree is closed; a parent still holding one would turn every EOF into a hang. - The trampoline marks the report close-on-exec after its descriptor sweep
(
close_inherited, thencloexec), so the program never inherits it. Theexecveof a macOS program closes it, which the parent reads as the start; on Linux no program, and no descendant of one, can write a falseendedor keep the reader from its EOF. - EOF before any record means started on macOS, and on Linux the envelope
died, which is
Refused. The two platforms’ trampolines end differently: macOS becomes the program, whose close-on-exec writer closes at theexecve; Linux supervises, and saysstartedaloud (the-trampoline-is-a-supervisor).
Why. The report is the one channel on which a confined, possibly hostile
child is believed about itself: a forged started hides a refusal, a forged
ended rewrites the program’s status. Authority over the channel is therefore
structural: the kind of file, the descriptor’s inheritance and the parent’s
copy are each fixed once, rather than checked at the reading.
See ral-s-failure-is-never-the-programs (whom each record blames), the-ending-is-amended-where-it-is-reaped, an-external-end-to-end and confined-launch.