SafeJIT: A Speculating JIT Engine Verified Down to the Machine Code
Abstract
JIT compilers are among the most attacked components of modern software. They compile attacker-chosen programs, speculate on attacker-influenced type feedback, and run the result at full native privilege. A single wrongly eliminated guard or a missing deoptimization becomes memory corruption. We present SafeJIT, a small JavaScript engine with a speculating baseline JIT, together with a machine-checked proof in Lean 4 that its statically linked RISC-V and x86-64 executables never crash, on any input, in a model of a Linux user process. The theorem is about the shipped binaries, executed instruction by instruction on Sail ISA models (for RISC-V, the official one), and it covers everything in them: the parser and bytecode compiler, the interpreter and its type-feedback recording, the JIT compiler, all machine code the JIT can generate for any program and any feedback (type guards, guard elimination, loop type facts, register allocation with deoptimization metadata, inline caches, deoptimization and on-stack replacement), a mark-sweep garbage collector, the runtime, and a freestanding libc. The C compiler, assembler and linker are not trusted, and neither is floating-point arithmetic. The proof uses separation logic (iris-lean) over a model of a Linux user process whose stuck states are exactly the ways a process can crash, including fetching code that has not been made executable or whose instruction cache has not been flushed.
Create a lesson
Related papers
CompCert4Lean: Porting a Verified C Compiler to Lean in Six Weeks with Parallel Coding Agents
Shared title terminologycs.PLCong Wang, Zhiyang Chen, Fan Long et al.
Detecting Empty Abstractions and Pruning Dead Paths in the Linux eBPF Verifier with Abstract Step Functions
Shared title terminologycs.PLHarishankar Vishwanatha, Srinivas Narayana, Santosh Nagarakatte
Python Code Generation for Isabelle/HOL
Shared title terminologycs.PLNikolaus Huber, Roly Perera, Dominic Orchard
DeCompCert: A Verified Decompiler for CompCert-Generated AArch64
Shared title terminologycs.PLSwarn Priya, Basavesh Ammanaghatta Shivakumar, Thomas Gilray et al.
Keel: A Verified In-Kernel Proof Checker for Proof Carrying BPF
Shared title terminologycs.PLYalu Cai, Tung-Che Chang, Santosh Nagarakatte
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
Shared title terminologycs.PLJinhua Wu, Yuting Wang, Zhemin Chen