Read first
docs/verification/tcb-discipline: every gate, what fails it, how to run itdocs/verification/framekernel: why only OSTD may holdunsafedocs/verification/ostd-trusted-core: how OSTD turns safety rules into typesdocs/development/unsafe-ffi-boundaries: adding an OSTD primitive or registry; style rulesdocs/verification/toolchain-gates: thescripts/check_*.shtoolchain and pin gatesdocs/verification/kernmiri: running OSTD's tests under Miridocs/verification/verus-status: what is proven and what a gate holds instead
Rules a change must keep
- Only
slopos-ostdwritesunsafe. Every other crate the kernel links keeps
#![forbid(unsafe_code)]; the one exempt file is kernel/src/main.rs.
- Never answer a gate by widening it: no allowlist entry (
SOURCE_ALLOWLIST,
SECTION_ALLOWLIST, SYMBOL_ALLOWLIST) without an audited reason, no
hand-raised cap; re-measure with --emit-allowlist. An entry that matches
nothing fails its gate, so remove it with the exemption.
- No
# Safetysection on a safe fn. Express the obligation as a type
(witness, validated newtype, one-shot handle, sealed trait, slice) or make
it unsafe fn inside OSTD.
- No
mem::forgetorManuallyDrop::newin kernel crates; a clippy exception
is a site-local #[expect(lint, reason = "...")], never a blanket allow.
- Kernel crates use OSTD's containers, never
alloc, and contain noasync. - A kernel frame stays under 2 KiB; nothing may exceed the 4 KiB guard page,
which no allowlist covers. Build large values in place.
- No x87, MMX, SSE or AVX instruction in the kernel (no target-feature
RUSTFLAGS, no vector asm!): kernel entry does not save that state.
- A new check is a Rust module in
tools/xtask(or a Go log gate in
tools/run_tests/gates/) with planted-violation tests, never a new
scripts/check_*.sh. Keep its //! invariant current.
- Default to no comment;
// SAFETY:,# Safetyonunsafe fn,///API
docs and asm register contracts are the exceptions.
Checks
cargo run -p slopos-xtask -- lint <gate>: one source gate (xtask listnames them)cargo run -p slopos-xtask -- elf --variant dev builddir/kernel-dev.elf: the per-build ELF gatesjust clippy kernel: clippy with the kernel's bansjust tcb-ratio: the unsafe-line ratio against its 1.0 % capjust test-host: every gate's own fixturesjust check-framekernel-gates: all source, ELF and script gates (afterjust build)
Not yet in the docs
Read pending.md beside this file when it exists. A change that adds or alters an invariant the docs do not state appends it there in the same commit.