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
omega-mv / seed / host / prlimit / README.md
| 1 | # prlimit (keyword 235) |
| 2 | |
| 3 | `prlimit pid res A off n` returns `long`: 0 or a negative errno from Linux |
| 4 | `prlimit64` (AArch64 syscall 261, x86-64 syscall 302). |
| 5 | |
| 6 | | operand | type | meaning | |
| 7 | |---|---|---| |
| 8 | | `pid` | int | target process; 0 is the caller | |
| 9 | | `res` | int | `RLIMIT_*` number (7 NOFILE, 9 AS, ...) | |
| 10 | | `A` | writable byte array | limit buffer; a `text` is error 20 | |
| 11 | | `off`, `n` | ulong | slice `A[off..off+n)`, checked first (trap 3) | |
| 12 | |
| 13 | - `n` 16 reads: new = NULL, the old `{rlim_cur, rlim_max}` lands in |
| 14 | `A[off..off+16)` as two little-endian u64. |
| 15 | - `n` 32 sets: the new pair is read from `A[off..off+16)`, the old pair is |
| 16 | written to `A[off+16..off+32)`. |
| 17 | - any other `n`: -22 with no kernel call. |
| 18 | - with `n` 32 the kernel itself also returns -22 (EINVAL) when the new soft |
| 19 | value is above the new hard value; that -22 does not mean a bad `n`. |
| 20 | |
| 21 | Program mode only: function mode is error 9, a contract clause error 30, |
| 22 | `target x86efi` error 25. Limits are inherited by `fork` and kept across |
| 23 | `execprog`. |
| 24 | |
| 25 | ## Gate |
| 26 | |
| 27 | `prlimit.cases`, run by the OM-2 conductor from `seed/host/check.sh`: |
| 28 | `OM2GATE PASS cases=15`. |
| 29 | |
| 30 | - `fixture`: `prlimit.om` on AArch64, all 16 checks against `/proc/self/limits` |
| 31 | (read, set soft NOFILE 40, EMFILE at fd 40, restore, -22 for bad `n` and |
| 32 | resource, -3 ESRCH, -1 EPERM on pid 1 unless root, RLIMIT_AS read, trap 3 on |
| 33 | both slice shapes, read and set at the unaligned offset 9, RLIMIT_AS 1 GiB |
| 34 | seen after `execprog`, a 128 MiB image killed under a 64 MiB cap, the same |
| 35 | image running uncapped). |
| 36 | - `x86-fixture`: `x86-target.om+prlimit.om` with argument `noas` (checks 1-12 |
| 37 | and 16; qemu-user ignores RLIMIT_AS writes). It runs through binfmt |
| 38 | qemu-x86_64: emulator evidence, not hardware qualification. |
| 39 | - refusals: `fnmode.om` (9), `contract.om` (30), `textarr.om` (20), |
| 40 | `longpid.om` (7), `efi-target.om+read16.om` (25), x86 `fnmode.om` (9). |
| 41 | - mutants: each `mutants/NAME.from` occurs once in `seed/omc/omc.om` and is |
| 42 | replaced by `NAME.to`; the fixture built by that compiler must fail at the |
| 43 | named check (exit = check number). |
| 44 | |
| 45 | | mutant | change | fixture exit | |
| 46 | |---|---|---| |
| 47 | | a64-sysno | `hsys 261` to 163 (getrlimit) | 1 | |
| 48 | | a64-swap | n 32 passes new = A+16, old = A | 3 | |
| 49 | | a64-nguard | the n == 32 test always taken | 7 | |
| 50 | | x86-sysno | `xhcall 302` to 97 (getrlimit) | 1 | |
| 51 | | x86-swap | n 32 passes rdx = A+16 | 3 | |
| 52 | | x86-nguard | the n == 32 test always taken | 7 | |
| 53 | | a64-nooff | `off` not added to the base (kernel gets &A[0]) | 16 | |