aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / docs / osc-receipts.md
| 1 | # OSC unit launch requires a realization receipt (aienos#383) |
| 2 | |
| 3 | Label for everything below: **QEMU (aarch64 virt), TEST signer, not physical.** Nothing here has run on a |
| 4 | Spark or any real machine. Contract: omega `spec/one-layer-receipts.md` (receipt v1, normative; section |
| 5 | numbers below refer to it). Gate: `scripts/qemu_ck_osc_receipt_test.sh` (`OSC_RECEIPT` row in |
| 6 | `scripts/ck_gates.sh`, notes in `native/kernel/GATES.md`). |
| 7 | |
| 8 | ## What it does |
| 9 | |
| 10 | A receipt is a 416-byte record, signed by a key of a stated class, saying that omega's independent checker |
| 11 | (checker2) judged one exact program (the OSC IR) and that one executable is bound to it by hash. The kernel |
| 12 | now refuses to launch an admitted OSC unit unless a receipt that is valid for that exact unit comes with the |
| 13 | launch. |
| 14 | |
| 15 | - `artifact/osc_receipt.{h,c}`: `osc_receipt_verify(receipt, len, &accept, &policy, &info)`, a pure function |
| 16 | written from the spec (no checker2 code copied). It reuses the in-tree SHA-256 and Ed25519 verify and |
| 17 | compares keys, hashes and identities in constant time. |
| 18 | - `core/osc_task.c`: `ck_osc_launch` takes the receipt bytes and verifies them with the kernel's own policy |
| 19 | (`ck_osc_policy`, `core/osc_admit.c`) before anything else; callers cannot pass a policy. A missing receipt |
| 20 | is `RECEIPT_MISSING`. Nothing is mapped and nothing runs on any refusal. The code is still copied and |
| 21 | re-hashed before mapping. |
| 22 | - `osc_unit_admit` and the container signature check are unchanged. A receipt grants no capability. |
| 23 | - Receipts reach the kernel as Store entries (magic `OMRCPT1`), kept by name (24 slots, 512 bytes each; a |
| 24 | longer entry is kept truncated so it is refused `RECEIPT_SIZE`). The self-test drivers pair a unit with its |
| 25 | receipt by name. |
| 26 | |
| 27 | ## Refusal codes |
| 28 | |
| 29 | Kernel code = 64 + the spec's stable reason number; the name is `RECEIPT_<spec name>`. Order is spec |
| 30 | section 6; the first failure decides. |
| 31 | |
| 32 | | code | name | when | |
| 33 | |---|---|---| |
| 34 | | 64 | RECEIPT_MISSING | no receipt (kernel only) | |
| 35 | | 65..71 | SIZE, MAGIC, VERSION, SIGNATURE_ALGORITHM, SIGNER_CLASS, EVIDENCE_CLASS, EPOCH_ORDER | structure | |
| 36 | | 73 | TEST_SIGNER_IN_PRODUCTION | release build and the receipt is not OWNER class | |
| 37 | | 74 | UNTRUSTED_SIGNER | fingerprint names no anchor of the receipt's class; a key in both classes; release mode and the owner key is not the owner root | |
| 38 | | 75 | BAD_SIGNATURE | | |
| 39 | | 76 | REVOKED | receipt id, then signer key fingerprint (`revoked=receipt_id` or `revoked=signer_key` on the launch line) | |
| 40 | | 77, 78, 79 | STALE_EPOCH, EXPIRED, NOT_YET_VALID | epoch window, inclusive at both ends | |
| 41 | | 86 | UNTRUSTED_CHECKER | checker identity not in the pinned list | |
| 42 | | 80..83 | WRONG_TARGET, WRONG_FIRMWARE, PROGRAM_MISMATCH, EXECUTABLE_MISMATCH | binding to the unit | |
| 43 | | 87 | WRONG_PRODUCER | the kernel's policy expects none (all zero) | |
| 44 | | 88 | DEPENDENCIES_MISMATCH | any dependency claimed | |
| 45 | | 96 | LRAT_PROOFS_REQUIRED | evidence class 2 (kernel-assigned number, see below) | |
| 46 | | 84 | ARGUMENT | verifier called without a unit or a policy | |
| 47 | |
| 48 | ## Kernel policy (`ck_osc_policy`) |
| 49 | |
| 50 | - Target: SHA-256(`"OMEGA-TARGET-V1\0"` ‖ `aienos-ck-aarch64-el0`). Program = the unit's IR hash (section 1). |
| 51 | Executable = the unit's code hash. Firmware: none (all zero). Dependencies: the empty list. Producer: none (all zero). |
| 52 | - Checker identity: one pinned identity, checker2 at omega 265ce82a (`artifact/osc_receipt_anchor.h`). |
| 53 | - Epoch floor 10, current epoch 20 (compile-time constants: there is no epoch authority yet). |
| 54 | - Owner receipt anchor (both builds, aienos#387): the owner root `578ada3c…` (`artifact/osc_receipt_anchor.h`), the |
| 55 | one OWNER anchor. `docs/OWNER_KEY_CEREMONY.md` section 7 records that it may sign realization receipts. |
| 56 | - Qualification build (`CK_SEED0B_TEST_ANCHOR=1`): in addition, checker2's TEST key is the TEST receipt anchor |
| 57 | (`artifact/osc_receipt_test_anchor.h`, separate from the unit TEST key) and one fixture receipt id is revoked. |
| 58 | - Release build: release mode and no TEST receipt anchor, so every TEST receipt is refused and an owner-signed |
| 59 | receipt can be valid. A release build still launches nothing: unit admission has no OWNER unit anchor until |
| 60 | TRUST-1, so no unit is admitted. |
| 61 | |
| 62 | ## Ambiguities in the spec, written down (no guess taken) |
| 63 | |
| 64 | 1. **Revoked id and revoked key share one code.** The brief asked for a reason of its own per case; the spec |
| 65 | gives both `REVOKED` (12). The kernel returns the spec code and says which list matched in a separate |
| 66 | field (`revoked=receipt_id|signer_key`). |
| 67 | 2. **Evidence class 2.** Section 6 accepts class 2 as well formed; section 10 says a class 2 receipt is valid |
| 68 | only when the same LRAT proofs are given and replayed, and names `LRAT-PROOFS-REQUIRED` without a number. |
| 69 | The kernel is given no proofs and has no LRAT checker, so it refuses class 2 (fail closed) with the |
| 70 | kernel-assigned code 96, after every section 6 step has passed (the spec does not place this check in the |
| 71 | section 6 order). |
| 72 | 3. **The "current epoch" and the floor** have no source in the spec beyond "the verifier's". The kernel uses |
| 73 | compile-time constants. |
| 74 | 4. **Producer.** The unit carries no producer identity, so the kernel policy names none (`NULL`), which |
| 75 | expects an all-zero producer field (`"none"`), matching `checker2 receipt verify` when no `--producer` |
| 76 | is given. The kernel and `checker2` agree on all 22 rows of `expected.txt`. |
| 77 | |
| 78 | ## UNVERIFIED (not done, not claimed) |
| 79 | |
| 80 | - **Physical Spark: NOT_RUN.** Only QEMU. No hardware, no GPU, no reboot. |
| 81 | - **OWNER receipts:** one exists (`tests/fixtures/osc_receipt_owner/a01.owner.rcpt`, signed on the owner YubiKey, |
| 82 | omega#455). It is accepted on the host and in QEMU only; no OWNER-signed unit exists, so no release image has run it. |
| 83 | - **Translation validation:** the executable is bound to the program by hash only (evidence class 1 says |
| 84 | so). Nothing shows the code implements the IR. |
| 85 | - **LRAT proofs** are not replayed in the kernel; class 2 is refused instead. |
| 86 | - **Requirements and input digests:** NOT CHECKED. |
| 87 | - **Dependency receipts:** not resolved; any claimed dependency is refused. |
| 88 | - **Container manifest** (entry table, capabilities, stack and tick budgets) is not bound by a receipt; it |
| 89 | stays bound by the unit signature only. |
| 90 | - **Epoch and revocation** are compile-time; there is no live revocation feed or epoch authority. |
| 91 | - **Name pairing** of unit and receipt in the self-test drivers is a test convenience; no Store-driven or |
| 92 | shell-driven launch exists yet. |
| 93 | - **Pre-existing non-OSC EL0 entry paths:** two pre-existing EL0 entry paths remain receipt-free: the |
| 94 | legacy P2 artifact `run_task` (`artifact_loader.c:810`) and the M3 self-test. Neither takes OSC units; |
| 95 | this change does not gate them. |
| 96 | |
| 97 | ## Tests |
| 98 | |
| 99 | - Host: `tests/test_osc_receipt.c` (in `make test` and `make sanitize`, qualification and release builds): |
| 100 | every case of `tests/fixtures/osc_receipt/expected.txt` (checker2's own verdict recorded beside the kernel's), |
| 101 | trust inputs against the fixtures, each structure reason and the order of the checks, epoch window edges, |
| 102 | all 3328 single-bit flips of a valid receipt refused, in-memory receipts re-signed with the published TEST |
| 103 | seed (reproducing checker2's signature byte for byte), the owner-signed receipt (VALID under the release |
| 104 | policy; every single-bit flip and the binding, epoch, checker and revocation controls refused; aienos#387), the |
| 105 | Store receipt table. |
| 106 | - Mutants: `make osc-receipt-mutants` removes each of the 25 guards in `osc_receipt.c` one at a time; the |
| 107 | test must fail for every one. |
| 108 | - QEMU: `scripts/qemu_ck_osc_receipt_test.sh`, 18 launches of one unit: the valid receipt runs it (first and |
| 109 | last launch), the owner receipt runs it in release mode (the qualification policy with release set, as for |
| 110 | the TEST-receipt release launch; the true release policy is covered by the host release build); every other |
| 111 | launch is refused with its own named reason and maps nothing. |
| 112 | - Fixtures: `tests/fixtures/osc_receipt/make-receipts.sh` (provenance in `PROVENANCE.txt`); the owner receipt is |
| 113 | copied from omega (`tests/fixtures/osc_receipt_owner/PROVENANCE.txt`). |