interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / effects / README.md

101 lines · 7029 bytes Raw Blame History Rendered
1# effects: capability manifest derived from Omega source
2
3A seeded-Omega program reaches the kernel only through the closed keyword set in
4[OMEGESE section 10](../../docs/one_layer/OMEGESE.md) and
5[MAPPING.md](../host/MAPPING.md): there is no raw syscall and no address-to-pointer
6conversion. The host words that appear in a unit are therefore a complete, finite list
7of the OS effects it can have. This tool turns that list into a manifest, checks it
8against the compiled binary, and emits a seccomp filter that enforces it.
9
10```
11seed/out/omc < seed/effects/effects.om > effects && chmod +x effects
12effects src [allow=C,..] < unit.om host words, classes, Linux syscalls; policy check
13effects elf < binary syscalls the omc ELF can issue (fail closed)
14effects verify SRC BIN [allow=C,..] ELF syscalls must lie within the source manifest
15effects bpf [launch] < unit.om seccomp cBPF allow-list for bwrap --seccomp
16effects table word, class and syscalls, one per line
17```
18
19Classes: `io` (read, write), `fd`, `path`, `net`, `proc`, `ident`, `time`, `env`,
20`random`, `device`, `mem` (`enlarge`: anonymous memory growth via mremap 216 / mmap 222,
21separated from `device` so verifiers need not allow GPU ioctl 29). `exit`/traps (syscall 93) are always allowed.
22
23Exit status: 0 pass, 1 refused or undeclared syscall, 2 usage, 3 invalid or
24unresolvable input, 4 read error.
25
26`elf` treats every SVC in an executable load segment as reachable. Each SVC must be
27immediately preceded by `MOVZ X8,#n`, and the segment may contain no `BR`/`BLR`; both
28rules apply to every word of the segment, instruction or not. No direct branch may land
29on an SVC. That rule applies to the words control can reach: omc puts texts in the same
30segment as the instructions, and a text can hold the bit pattern of a branch (the four
31bytes `@-(6` read as `TBZ`), so holding data to it refused correct programs, omc itself
32among them. Reach starts at the entry word and follows the next word and the target of
33every direct branch; it stops after an unconditional `B`, a `RET`, and an SVC whose
34number is 93 or 94 (exit, exit_group). Such an SVC does not return, and the reason is part
35of the rule: it can be entered only through the `MOVZ X8` before it, because a reached
36branch onto it is refused and an entry point on an SVC is refused, so X8 holds 93 or 94
37when it runs. Reach must not lose control, so three more things are refused: an entry
38point that is an SVC, a reached direct branch whose target lies outside the segment, and
39a reached word that falls through past the last word of the segment. A reached
40register-branch instruction other than `RET` (the pointer-authentication forms, `ERET`) and
41a reached `BC.cond` are refused as well, because the walk cannot follow them. When the entry point
42is not in the segment, every word is held to the rule. Anything else is `ELF UNRESOLVED`
43(exit 3). W+X segments are refused. A binary from another producer will usually fail
44closed.
45
46What this does not show: that a `RET` returns to the word after a `BL`. The calling
47sequence the compiler emits is relied on for that, as it was before this rule was narrowed.
48
49## Qualification
50
51`sh seed/effects/check.sh` (pinned omc; strace, bwrap, od and dd as oracles):
52
53- closure: every keyword with a host code in `seed/omc/genkw.awk` (all `split("…")` lists,
54 found by content) is in the table, except `const`/`qty` (types), `cpufence`/`cpurelax`,
55 which lower to `DSB SY`/`YIELD`, and `fma` (fused multiply-add, one `FMADD`); a probe shows
56 they add no syscall beyond exit (93). The VFIO words are `device` (`vfioctl`, `vfioirq`:
57 ioctl 29; `vfiomap`, `vfiomapw`: mmap 222) and `eventfd` is `fd` (eventfd2 19). `enlarge` (run-time
58 pools) maps the process's own anonymous memory and is in the dedicated `mem` class (mmap 222 at the
59 first growth, mremap 216 past the capacity) so verifiers can grow pools without allowing `device` ioctl 29.
60 `omc.om` has exactly 7 SVC emit sites (a new site means the table needs review); `fn en_help` holds
61 two of them, the omc_enlarge helper's mremap and mmap
62- probe parity: one compiled probe per word; the ELF syscalls equal the table row. A row
63 lists any number of syscalls (`execpure` lowers to ten, `execprog` to execve and close_range). A word
64 that cannot be an expression names a whole probe program instead (`enlarge|@probe-enlarge.om` in
65 `cases/probes.txt`)
66- self manifest, fixtures, policy refusals with word, class and line
67- every program-mode unit in `seed/host/tests` and `seed/rung4/tests`, and omc itself:
68 binary syscalls lie within the source manifest
69- strace: syscalls observed at run time lie within the ELF set
70- seccomp: each fixture runs under its own filter; a binary run under a narrower
71 filter is killed (exit 159, SIGSYS)
72- fail-closed controls: SVC without `MOVZ X8`, `MOVZ X9`, branch into an SVC, `BR`,
73 W+X segment, non-ELF input, a syscall number of 512 or more, no executable segment; the
74 last two also check the reason text, which was empty before because the message numbers
75 in the source pointed past the end of the message table
76- data is not code: a text word patched into a `B` onto an SVC behind the entry branch,
77 behind a `RET` and behind an exit SVC passes with the syscalls of the unpatched binary
78 (`cases/tb-entry.om`, `tb-ret.om`, `tb-exit.om`); the same word is refused once the entry
79 word branches to it; a `B` onto the SVC in the word after a returning SVC is refused; an
80 entry point outside the segment holds every word; an entry point off a word boundary is
81 invalid; an entry point on an SVC, a reached branch to past the end or to before the start
82 of the segment, a reached word that falls off the end, a reached `BRAAZ` and a reached
83 `BC.cond` are refused; a text word with the `BRAAZ` pattern passes
84- tool mutants are killed, each by the control named for it in `check.sh`: dropped row,
85 wrong syscall number, weakened MOVZ check, every word held again, nothing held, the
86 outside-entry fallback off, fall-through after `B`, after `RET` and after exit, and the
87 entry-SVC, leaves-segment and falls-off-the-end refusals each removed, and the two
88 message numbers put back wrong, and the two unknown-branch refusals each removed
89
90## Limits
91
92- Classes and the filter work at syscall granularity. `fopen` is `path` whether it
93 reads or writes; argument-level policy (literal open flags, socket families) is
94 future work.
95- `bpf launch` adds `execve` (221) so that bwrap can start the program. The program
96 can therefore call execve itself under that filter. An in-program install would close
97 this gap but needs a `prctl`/`seccomp` host word, which is a compiler change.
98- The filter restricts syscalls only. The check runs bwrap with `--dev-bind / /`, so
99 filesystem and namespace isolation are separate.
100- The table is pinned to the compiler in `om/units.sh`. A compiler that changes how
101 host words lower is caught by closure and probe parity, not silently accepted.