150 likes | 269 Views
Report on Project CComp. Zhaopeng Li Joint work with Prof. Yiyun Chen, Zhong Zhuang, Simin Yang, Dawei Fan, Zhenting Zhang Software Security Lab., USTC, Suzhou, China August 1, 2009. Motivation. “Friendly” Program verification A prototype for research on: Certifying Compiler
E N D
Report on Project CComp Zhaopeng Li Joint work with Prof. Yiyun Chen, Zhong Zhuang, Simin Yang, Dawei Fan, Zhenting Zhang Software Security Lab., USTC, Suzhou, China August 1, 2009
Motivation • “Friendly” Program verification • A prototype for research on: • Certifying Compiler • Automated Theorem Prover • Proof Building /Generation
Research Objects (1) Certifying Compiler /*n>0 | emp*/ struct list* list_create(int n) { … while(n>0) /*n>=0 | list(p)*/ {… } return p; } /* true | list(res)*/ List_create: push ebp mov esp, ebp sub esp, 8 jmp L0 L0 : … L1 : Lemma wf_L0: … Lemma wf_L1: … Lemma … CComp Compiler C-like language SCAP Framework
Research Objects (2) Automated Theorem Prover Prover for fragment of Separation Logic Linear Arithmetic Prover Formulas Proof (Proof Term Checkable by Coq) Other Domain-Specific Provers (list, and etc.) Proof Tree Proof Output Automated Theorem Prover Fragment of Separation Logic : separation star / emp / p|->_ Build-in Predicates : list/lseg/dlist/dlseg/tree…
Research Objects (3) Proof-Building/Generation /*n>0 | emp*/ struct list* list_create(int n) { … while(n>0) /*n>=0 | list(p)*/ {… } return p; } /* true | list(res)*/ List_create: push ebp mov esp, ebp sub esp, 8 jmp L0 L0 : … L1 : Lemma wf_L0: … Lemma wf_L1: … Lemma … CComp Compiler Proof-Building/ Generation High Level: VCGen-based Verification VC + Proof C-like language SCAP Framework
Clike Front-end SCAP (modified for CComp) IRGen SpecGen Algorithm (partial) VCGen (still some bugs) ProofGen Design Theorem Prover: linear arithmetic (with coq-checkable proof) Theorem Prover: fragment of separation logic (list, lseg) Current Status IRCode x86Code IRGen SCAP package x86Gen Clike Front-end VC Prf. VC Prf. Spec. SpecGen VCGen ProofGen Theorem Prover
SCAP (modified for CComp) • Abstract Machine • Explicit Stack • Inexplicit Stack Register • Stack K ::= (webp, wesp, w::w:: … ::nil) • Reg&Instruction • No ebp, esp as register • enter/leave in prolog/epilog • Special move instruction for load/store on stack
Specification Generation for SCAP • Specification (p,g) • Every label • Each program point • Pre-/Post-condition • Generate p • Generate g • By • Operation semantics • Source-level specifications • pre-/post-conditions • loop invariants p S enter x jmp L1 L1 : {(p1, g1)} Basic block2 g S S’ leave ret
Figure Out G G: State -> State -> Prop R f : {R’(ebp)=R(ebp)/\R’(esp)=R(esp)+4} push ebp mov esp, ebp sub $12, esp R0(ebp) = R(ebp) /\ R0(esp) = R(esp) -4 R’(ebp) = R0(ebp) /\ R’(esp)=R0(esp)+8 R0 R’(ebp) = R(ebp) /\ R0(ebp) = R(ebp) /\ R’(esp)=R(esp)+4 /\ R0(esp) = R(esp) -4 g0 L1 : {g1} Basic block2 • The method: • Get state relation by rule of operational semantics; • Use the g of previous program point; • Do substitution and arithmetic. Leave ret R’
Figure Out G (cont.) R f : {R’(ebp)=R(ebp)/\R’(esp)=R(esp)+4} push ebp mov esp, ebp sub $12, esp R’(ebp) = R0(ebp) /\ R’(esp)=R0(esp)+8 R0 g0 R1 R1(ebp) = R0(esp) /\ R1(esp) = R0(esp) R’(ebp) = M1(R1(ebp)) /\ R’(esp)=R1(esp)+8 R’(ebp) = R0(ebp) /\ R1(ebp) = R0(esp) /\ R’(esp)=R0(esp)+8 /\ R1(esp) = R0(esp) g1 L1 : {g1} Basic block2 • The method: • Get state relation by rule of operational semantics; • Use the g of previous program point; • Do substitution and arithmetic. Leave ret R’
Figure Out G (cont.) R f : {R’(ebp)=R(ebp)/\R’(esp)=R(esp)+4} push ebp mov esp, ebp sub $12, esp R’(ebp) = R0(ebp) /\ R’(esp)=R0(esp)+8 R0 g0 R1 R’(ebp) = M1(R1(ebp)) /\ R’(esp)=R1(esp)+8 g1 R2 R2(ebp) = R1(ebp) /\ R2(esp) = R1(esp)-12 R’(ebp) = M2(R2(ebp)) /\ R’(esp)=R1(esp)+20 L1 : {g1} R’(ebp) = M1(R1(ebp)) /\ R2(ebp) = R1(ebp) /\ R’(esp)=R1(esp)+8 /\ R2(esp) = R1(esp)-12 Basic block2 g2 • The method: • Get state relation by rule of operational semantics; • Use the g of previous program point; • Do substitution and arithmetic. Leave ret R’
On-Going Work • Automated Theorem Prover on • Fragment of separation logic • Build-in predicates: tree, dlist, dlseg,… • Proof term output • Back-end • Specification Gen for SCAP • Generation SCAP package
Work to Do • Improve the Theorem Prover • Add more theory needed • Run some Benchmark • Complete and improve the Compiler • Engineering on back-end • More test cases, more testing • Papers on: • CComp • Automated Theorem Prover • SCAP(modified) and SpecGen
Demonstration • Simin Yang • Linear Arithmetic Prover • Test cases on arithmetic examples • Zhong Zhuang • Prover for fragment of separation logic • Test cases on list and cyclic list • Zhenting Zhang • Building Proof of VC in IR using Clike VC • Test cases on linear arithmetic