Combining Type Checking and Formal Verification for Lightweight OS Correctness
Ramla Ijaz, Kevin Boos, Lin Zhong
TL;DR
This work demonstrates a practical path to OS correctness by combining Rust's type system with selective formal verification and informal reasoning. The authors develop an Intralingual Representation System (IRS) that uses linear types and typestates to model resources as unique representations whose access is compiler-checked, and they pair this with a hybrid verification approach to extend invariants beyond what the type system alone can guarantee. Applied to Theseus memory management and the ixgbe NIC driver, the approach yields substantial proof-effort reductions (e.g., memory subsystem ratio $1:117$, ixgbe driver ratio $1:8.3$) with negligible runtime overhead, while still achieving important invariants like bijective page-frame mappings. The resulting framework supports correctness-by-construction while maintaining practicality for real systems, and it uncovers and prevents bugs that elude traditional approaches, offering a scalable path toward safer Rust-based OS software.
Abstract
This paper reports our experience of providing lightweight correctness guarantees to an open-source Rust OS, Theseus. First, we report new developments in intralingual design that leverage Rust's type system to enforce additional invariants at compile time, trusting the Rust compiler. Second, we develop a hybrid approach that combines formal verification, type checking, and informal reasoning, showing how the type system can assist in increasing the scope of formally verified invariants. By slightly lessening the strength of correctness guarantees, this hybrid approach substantially reduces the proof effort. We share our experience in applying this approach to the memory subsystem and the 10 Gb Ethernet driver of Theseus, demonstrate its utility, and quantify its reduced proof effort.
