Skip to Content
axiomOSmainSecurityUnsafe-Code Audit

Unsafe-Code Audit

Relevant source files

Every first-party Rust unsafe syntax site is an owned review obligation. ledger.toml is the maintained catalog (path rules, owners, invariants); ledger.md is generated from it plus the current source by python3 scripts/verify/unsafe-ledger.py --write. Review and CI run cargo xtask check unsafe; --list prints a per-site TSV (location, construct, owner, invariant, callers, tests, priority, review date).

Snapshot

694 sites in 121 files: 153 attributes, 432 blocks, 25 externs, 62 functions, 21 impls, 1 trait. Counts are syntactic source sites (including tests and fuzz targets, excluding build output and corpora), not expanded macro instances and not a proof of soundness. The inventory is fingerprinted (sha256:7da4b56b...) so drift is detected.

Obligations

ObligationSitesPriorityInvariant (abridged)Missing evidence called out
AARCH64-EXCEPTION-CONTEXT86P0Assembly context layouts match repr(C); vectors preserve registersNested exception and SMP interrupt stress
TEST-HARNESS88P3Synthetic pointers confined to test/fuzz binaries(harness is the evidence)
SCHEDULER-TASK61P0One mutable owner of task/CPU state; context pointers pinnedLoom/model tests, forced preemption at mutation points
AARCH64-PLATFORM-MMIO57P1MMIO matches DT/platform map; volatile, width-correct accessRegister-level mocks, concurrent ownership tests
BPF-EXECUTION-JIT47P0Only VerifiedProgram reaches execution; W^X for generated codeJIT differential tests, enforced RW-to-RX lifecycle
USERSPACE-ABI45P1Syscall asm obeys kernel ABI; ring buffers aligned and boundedMiri for parsers, malformed ring/event inputs
KERNEL-BOOT-RUNTIME40P1Bootloader pointers, linker symbols, allocator setup validMalformed boot metadata, backtrace-chain tests
AARCH64-PAGING38P0Aligned, uniquely owned tables; TLB maintenance orderedMap/unmap fault injection, multicore shootdown tests
MEM-ADDRESS-SPACE35P0Page tables live under the address-space lock; user copies validate every pageConcurrency fault injection
BPF-HELPERS32P0Verified helper args still refer to live regions at run timeAdversarial helper provenance, concurrent map lifetime
SYSCALL-PRIMITIVES29P0UserspacePtr proves only numeric range; deref needs UserMemoryTargeted Miri
X86-INTERRUPT-CONTEXT25P0Naked frames match Rust layouts; valid stacks/selectorsNested interrupt, malformed-frame tests
DMA-MMIO-DRIVERS25P1MMIO/DMA mapped for device lifetime; transport serializedIOMMU/DMA fault injection, hot-unplug
MEM-PHYSICAL14P0Frame allocator initialized once, never hands out aliased framesSMP allocator stress, reserved-range fault injection
SCHEDULER-RUN-QUEUE14P1Intrusive links preserve task uniquenessSMP-4 wakeup/IPI integration
FILESYSTEM-INTERIOR13P1Interior raw references do not outlive nodesConcurrent close/read/unmount
BPF-KERNEL-INTEGRATION10P0Registry preserves program, credential, quota, lifetime invariantsModel-checked reclamation
MEM-KERNEL-RAW9P1Raw allocation uses live mapped memory with exact layoutMiri for host-capable primitives
SYSCALL-BOUNDARY9P0Register values untrusted; memory only via bounded adapterFull syscall fault matrix
BPF-MAPS9P0Map pointers aligned, in-bounds, live; Send/Sync premises holdMiri/Loom, unload-during-execution tests
MEM-VIRTUAL3P0Released segments not double-released or overlappingTransactional map/unmap integration tests
RISCV-ARCH2P1Trap/context asm matches layouts (experimental demo)Boot/trap integration
SCHEDULER-WAIT-TRANSITION1P0Generation-stamped wait registration, IRQs masked across transition(model + SMP smoke present)
ACTUATION-MMIO1P1RP1 GPIO window mapped for kernel lifetime, singleton ownershipConcurrent ownership, MMIO fault injection
FIRMWARE-MMIO1P1RP2040 peripheral singletons accessed exclusivelyHardware concurrency, timer wraparound

Review policy

  • P0 gates release until the premises are enforced in code and exercised through a fault or concurrency path. P1 needs targeted tests before the subsystem is complete. P2 is platform/ABI glue with documented external premises. P3 is test/tooling only.
  • The path rule is the durable owner; a new path containing unsafe fails --check until classified, and any count drift fails --check.
  • “Boot smoke” is integration evidence, not a substitute for provenance, aliasing, lifetime, mapping, interrupt, DMA or MMIO tests. Rows that say coverage is missing remain open audit debt.
  • Contributor rule: every unsafe block needs a SAFETY: comment.

The BPF-EXECUTION-JIT obligation still exists because JIT code remains in the tree (kernel_bpf/src/execution/jit_aarch64.rs, execution/jit), even though no shipped profile enables it. ADR-0004 calls for removing or relocating it precisely because dead unsafe code adds audit surface.

Last updated on