The defect taxonomy
Every memory-corruption defect in the project's history adjudicated individually: methodology, the residency split, representative rows, the panic-surface containment and the negative-result archive β data answering "is a Rust kernel actually safe" Β· Canonical: docs/architecture/safety-and-performance.md Β§2
Β§1Methodology
- Corpus: every 3,358 deduplicated non-merge commit subject reachable from main (2,702 kernel-code subjects) + the hunt-ledger entries.
- Screening: 169 candidate commits matching corruption/race/panic vocabulary, each individually adjudicated, finalized over three sweeps (2026-11-03).
- Residency determination: each memory-corruption row's fix diff is inspected block by block to establish whether the defect lived in an explicit unsafe block, arch assembly, an unsafe interior (UnsafeCell allocator metadata, raw-pointer protocols), or safe code.
- Accounting discipline: containment-only commits do not count as defects; revert-and-reland pairs count once; instrument false positives do not count as kernel defects.
Β§2The headline statistics
| Measure | Count | Meaning |
|---|---|---|
| Memory-corruption-class defects (all history) | 33 | each with its fix commit and reproduction/regression evidence |
| β defect inside an explicit unsafe block / arch assembly / unsafe interior | 23 | raw-pointer protocols, UnsafeCell allocator metadata, trap assembly |
| β defect in safe code | 10 | every one in a class safe Rust does not type-check today: ownership/refcount/lock-protocol/stack-depth decisions executed through a trusted unsafe boundary or an unguarded stack |
| Pointer-expression classes (index overrun / iterator invalidation / wild pointer arithmetic / format strings) | 0 | the expression-level classes that dominate C-kernel CVE history are compile errors here |
| Caught by review before any boot | 6 / 33 | review works as an independent defense line |
The methodology's self-correction, on record: a draft claimed "zero defects in safe code" β the full-history sweep falsified it (10 safe ownership-class defects), and the final version uses the residency basis. Conclusions follow data, not narrative.
Β§3Representative rows
Unsafe-class (3 examples)
- kthread pt_regs zeroing: a write_bytes element-count of 168Γ168 B overran by 28,224 bytes across adjacent pages (live buffer-cache/inode blocks zeroed) (d047afad).
- x86 entry EFLAGS.DF dirty: a user-set DF not cleared reversed rep movsb copies (the scribble engine's root cause) (e7070224).
- buddy split left the final block unmarked as allocated: the same memory handed out twice (FdTable 8KB Vec corrupted, fork hangs) (016b3fa1; allocator-interior UnsafeCell metadata).
Safe-class (3 examples β all in the type system's blind spots today)
- vmscan freed at refcount β€ 0 (the zone double-free enabler) (f4b67f66) β motivated the checked-Refcount-newtype proposal (a hardening gap on record).
- The GRQ keyed-lock swap discarded the returned guard: the lock released silently at end-of-statement and every critical section ran unexcluded; established by a 13-boot paired bisection; keyed guards carry #[must_use] since β the same API-shape bug is now a compile warning (2b092c49/623c4736/75dbf637).
- PCACHE_SHARED defined as bit 10: bit 10 is PPN[0] in Sv39, so every shared mapping aliased a frame 4 KiB off the cache page (silent neighbor-page corruption); caught by snapshot review before any boot ran (6b49140b).
Caught-in-review examples (selection)
- aarch64 boot.S DTB-pointer register clobber (6e808eea); devfs Arc::as_ptr without an owning clone (the "safe storage β unsafe deref" boundary) (69f45692); an unchecked io_uring SQE index in a raw-pointer read (5465735f); recvmsg re-fetching the user iovec after validation (a safe-code TOCTOU) (32fd359f).
Β§4Boundary rows (listed separately, not in the 33)
- mremap in-place expansion over merged-VMA neighbours (56fc7e8b); the R71 file-position race (c17f6ec0); VMA surgery atomicity (56b2baeb); ext4 stale extents (2f9763fc); the per-task program break (A/B 3/12 boots hit β 0/12) (c127e4bc1/f6e3b8837) β semantic-level defects are filed separately to avoid confusing them with the memory-corruption class.
Β§5The panic surface: designed, not latent
The kernel's panic paths are a designed surface: every found instance is eliminated with a regression test, not filed away as a CVE class. The governing principle: loud failure beats silent corruption β a bounds check turns an overrunning write into a panic instead of letting the damage propagate.
- Evidence: the pcp refill race's racing store hit a bounds-checked index and panicked explicitly ("the len is 32 but the index is 32", 165ee5fce) β the race existed but the corruption was unreachable.
- The containment list (selection): the UTF-8 printer family (a non-UTF-8 comm broke the panic printer at t=209s, f0c57182/3ad32b9e), the stale negative-memo null dereference (ea26d923), the mmprof scalar-slot namespace (276c2e70), the dfx switch-table overrun (363401cd), the memwatch PFN bound (cbd41b40), the R81 garbage-pid case (2c044bb5), the R73 stack-walk bound (9777f195), taskdump (bf995f2a), the ext4 empty index root (b70a5deb), aarch64 trap-report regs[31] (363ac70b), binder dead-proc expect β bounded warning (619bf4b6), the timer same-CPU IRQ-reentrancy family (186a00b6), Wave-1's eleven items (83d0b691), get_cwd UB + UTF-8 cmdline (830e3f8c).
Β§6The negative-result archive (with receipts)
- Instruments were also found at fault: PTGUARD/FREEGUARD were misdiagnoses (e61f7a3a); the first PT_LEDGER hash design produced false DOUBLE-FREE reports plus real frame leaks (626658991200); the 2b092c49 "latent GRQ race" theory was wrong. Negative results with receipts stay in the record β the adjudication discipline is itself audited.
Β§7The verdict: what these numbers support
- The class-elimination argument holds: zero expression-level defects is consistent with safe code's structural immunity; 23 of 33 defects reside in explicitly audited unsafe β self-consistent with the layered model where the unsafe surface IS the TCB (7.1% of area / 14.0% on the dual series, the ledger).
- The residual class is named and addressed: the 10 safe-class defects are all ownership/refcount/lock-protocol/stack-depth decisions β precisely the targets of model checking and property testing (loom lock protocols, Kani INV-M tables, proptest refcounts); the hardening register lists checked Refcount and stack-depth analysis as closure items.
- The defense lines work: 6/33 caught by review before any boot; panic surfaces contained instance by instance; instrument misjudgments archived.
- A statement without hedging: 33 defects over 3,358 commits β 1% of all commits carried a memory-corruption defect, each with a fix and regression evidence β this is the empirical baseline for "safe enough", not an assertion.
Reproduce and canonical source: docs/architecture/safety-and-performance.md Β§2 (the full 33-row table + boundary rows + the panic containment list + the negative-result archive). Related: the layered unsafe ledger, formal verification.