| ▲ | dnautics 2 hours ago | |
One of the most interesting things is how Sel4 works -- IIUC they compile to arm64 assembler, and then run verification proofs on that. Inspired by that, I think that an interesting place to patch verification in to an existing language is at the IR level. At the IR level, you have usually (effectively) a highly-regularized schema for all operations, that is usually still embued with semantic information (for example: the function you called is "malloc") that can be used to generate invariants that you'd like to prove (or refute). Of course you still have to trust that the IR->ASM part of the compiler is good, but at least the program logic has been verified. | ||
| ▲ | danilafe 24 minutes ago | parent | next [-] | |
This is an interesting idea. At its core, IRs tend to be smaller and have better defined semantics. Of course, you'd have to use something other than the IR itself as the metalanguage (not a problem, though). Perhaps the reason this hasn't been attempted as often (I read the sibling Sel4 discussion about refinements) is twofold: 1. The mechanical effort required to show that the IR satisfies some abstract specification. Sel4 requires several refinement proofs (I am trusting the sibling comment on this), which suggests a great deal of effort. Perhaps LLMs (taken as "smart heuristics for proof code generation") can be of use here. 2. IR serves a secondary purpose as a target for compiler transformations. I've written myself about formally verifying compiler analyses[1] and I've proven a rudimentary LICM optimization in Lean based on these analyses (I haven't had a chance to write that one up), but it took a great deal of effort. We may then be forced either not to optimize or to trust something like LLVM (but...here be dragons? :P ). So there is a tension between "simple core language" and "mutable substrate for optimization". And that doesn't even bring into question MLIR dialects and progressive lowering! [1]: https://danilafe.com/series/static-program-analysis-in-agda/ | ||
| ▲ | saithound an hour ago | parent | prev [-] | |
You write: > One of the most interesting things is how Sel4 works -- IIUC they compile to arm64 assembler, and then run verification proofs on that But that's not how seL4 works. The seL4 proofs are refinement proofs. No assembly is involved, and the verification work is done on the abstract mathematical spec, and the C implementation. Here's how it works: 1. They write a mathematical specification in Isabelle. 2. They prove good security properties about the mathematical specification. They show that a correct implementation of the specification wouls prevent applications running on top of it from modifying data without authorisation (integrity), from interfering with resource access of other applications (availability), and from learning information from other applications without explicit authorisation (confidentiality). 3. They prove (in Isabelle, an interacrive theorem prover) that a Haskell program refines an abstract Isabelle specification, then prove that the C implementation of seL4 refines the Haskell program. 4. They compile the C program using gcc, then prove (using an automated tool) that the machine code was compiled correctly. This works on ARM and RISC-V. Assembly is not involved in the proof, only machine code and C code. 5. Together, the chain of refinements in 3,4 imply that the running binary correctly implements the mathematical specification. Sincw the specification satisfies the good properties, so does the implementation. In other words, the seL4 KERNEL prevents applications running on top of seL4 from modifying data without authorisation (integrity), from interfering with resource access of other applications (availability), and from learning information from other applications without explicit authorisation (confidentiality). Together these security properties enforce the isolation of components running on top of the kernel, allowing critical components to securely run alongside untrusted software. | ||