Automatic Predicate Abstraction of C Programs Thomas BallMicrosoft Rupak MajumdarUC Berkeley Todd MillsteinU Washington Sriram K. RajamaniMicrosoft

Slides:



Advertisements
Similar presentations
A SAT characterization of boolean-program correctness K. Rustan M. Leino Microsoft Research, Redmond, WA 14 Nov 2002 IFIP WG 2.4 meeting, Schloβ Dagstuhl,
Advertisements

Assertion Checking over Combined Abstraction of Linear Arithmetic and Uninterpreted Functions Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Advanced programming tools at Microsoft
The SLAM Project: Debugging System Software via Static Analysis
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Semantics Static semantics Dynamic semantics attribute grammars
Lecture #21 Software Model Checking: predicate abstraction Thomas Ball Testing, Verification and Measurement Microsoft Research.
Bebop: A Symbolic Model Checker for Boolean Programs Thomas Ball Sriram K. Rajamani
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
1 Thorough Static Analysis of Device Drivers Byron Cook – Microsoft Research Joint work with: Tom Ball, Vladimir Levin, Jakob Lichtenberg,
Chair of Software Engineering Software Verification Stephan van Staden Lecture 10: Model Checking.
Automatic Predicate Abstraction of C-Programs T. Ball, R. Majumdar T. Millstein, S. Rajamani.
Thomas Ball, Rupak Majumdar, Todd Millstein, Sriram K. Rajamani Presented by Yifan Li November 22nd In PLDI 01: Programming Language.
1 Automatic Predicate Abstraction of C Programs Parts of the slides are from
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Discrete Structures Lecture 29 Predicates and Programming Read Ch
Predicate Transformers
Verification of parameterised systems
BLAST-A Model Checker for C Developed by Thomas A. Henzinger (EPFL) Rupak Majumdar (UC Los Angeles) Ranjit Jhala (UC San Diego) Dirk Beyer (Simon Fraser.
The Software Model Checker BLAST by Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala and Rupak Majumdar Presented by Yunho Kim Provable Software Lab, KAIST.
Using Statically Computed Invariants Inside the Predicate Abstraction and Refinement Loop Himanshu Jain Franjo Ivančić Aarti Gupta Ilya Shlyakhter Chao.
Assertion Checking Unified Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Lazy Abstraction Thomas A. Henzinger Ranjit Jhala Rupak Majumdar Grégoire Sutre UC Berkeley.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Synergy: A New Algorithm for Property Checking
Secrets of Software Model Checking Thomas Ball Sriram K. Rajamani Software Productivity Tools Microsoft Research
Hoare-style program verification K. Rustan M. Leino Guest lecturer Rob DeLine’s CSE 503, Software Engineering University of Washington 26 Apr 2004.
Speeding Up Dataflow Analysis Using Flow- Insensitive Pointer Analysis Stephen Adams, Tom Ball, Manuvir Das Sorin Lerner, Mark Seigle Westley Weimer Microsoft.
CS 267: Automated Verification Lectures 14: Predicate Abstraction, Counter- Example Guided Abstraction Refinement, Abstract Interpretation Instructor:
Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball and Sriram K. Rajamani Software Productivity Tools, Microsoft Research Presented.
Building a program verifier K. Rustan M. Leino Microsoft Research, Redmond, WA 10 May 2006 Guest lecture, Shaz Qadeer’s cse599f, Formal Verification of.
Predicate Abstraction for Software and Hardware Verification Himanshu Jain Model checking seminar April 22, 2005.
From last time S1: l := new Cons p := l S2: t := new Cons *p := t p := t l p S1 l p tS2 l p S1 t S2 l t S1 p S2 l t S1 p S2 l t S1 p L2 l t S1 p S2 l t.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Describing Syntax and Semantics
Lazy Abstraction Tom Henzinger Ranjit Jhala Rupak Majumdar Grégoire Sutre.
50.530: Software Engineering
Software Model Checking with SLAM Thomas Ball Testing, Verification and Measurement Sriram K. Rajamani Software Productivity Tools Microsoft Research
Verification of Java Programs using Symbolic Execution and Loop Invariant Generation Corina Pasareanu (Kestrel Technology LLC) Willem Visser (RIACS/USRA)
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 3: Modular Verification with Magic, Predicate Abstraction.
Rule Checking SLAM Checking Temporal Properties of Software with Boolean Programs Thomas Ball, Sriram K. Rajamani Microsoft Research Presented by Okan.
SAT & SMT. Software Verification & Testing SAT & SMT Test case generation Predicate Abstraction Verifying Compilers.
Newton: A tool for generating abstract explanations of infeasibility1 The Problem P (C Program) BP (Boolean Program of P) CFG(P) CFG(BP)
CS 363 Comparative Programming Languages Semantics.
Thomas Ball Sriram K. Rajamani
Use of Models in Analysis and Design Sriram K. Rajamani Rigorous Software Engineering Microsoft Research, India.
Predicate Abstraction of ANSI-C Programs Using SAT By Edmund Clarke, Daniel Kroening, Natalia Sharygina, Karen Yorav Presented by Yunho Kim Provable Software.
Reasoning about programs March CSE 403, Winter 2011, Brun.
Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball, Sriram K. MSR Presented by Xin Li.
Chapter 3 Part II Describing Syntax and Semantics.
SLAM internals Sriram K. Rajamani Rigorous Software Engineering Microsoft Research, India.
The Yogi Project Software property checking via static analysis and testing Aditya V. Nori, Sriram K. Rajamani, Sai Deep Tetali, Aditya V. Thakur Microsoft.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
1 Automatically Validating Temporal Safety Properties of Interfaces - Overview of SLAM Parts of the slides are from
1 Proving program termination Lecture 5 · February 4 th, 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
Counter Example Guided Refinement CEGAR Mooly Sagiv.
Boolean Programs: A Model and Process For Software Analysis By Thomas Ball and Sriram K. Rajamani Microsoft technical paper MSR-TR Presented by.
Software Model Checking with SLAM
Semantics In Text: Chapter 3.
Predicate Transformers
50.530: Software Engineering
Predicate Abstraction
Course: CS60030 Formal Systems
Presentation transcript:

Automatic Predicate Abstraction of C Programs Thomas BallMicrosoft Rupak MajumdarUC Berkeley Todd MillsteinU Washington Sriram K. RajamaniMicrosoft

do { //get the write lock AcquireLock(&dev->lock); nPacketsOld = nPackets; request = dev->WriteListHeadVa; if( request && request->status ){ dev->WriteListHeadVa = request->Next; ReleaseLock(&dev->lock); irp = request->irp; if(request->status > 0){ irp->IoStatus.Status = STATUS_SUCCESS; irp->IoStatus.Information = request->Status; } else{ irp->IoStatus.Status = STATUS_UNSUCCESSFUL; irp->IoStatus.Information = request->Status; } SmartDevFreeBlock(request); IoCompleteRequest(irp, IO_NO_INCREMENT); nPackets++; } } while ( nPackets != nPacketsOld ); ReleaseLock(&dev->lock); Question: Is locking protocol respected? Verifying Temporal Properties of Software

do { //get the write lock AcquireLock(&dev->lock); nPacketsOld = nPackets; request = dev->WriteListHeadVa; if( request && request->status ){ dev->WriteListHeadVa = request->Next; ReleaseLock(&dev->lock); irp = request->irp; if(request->status > 0){ irp->IoStatus.Status = STATUS_SUCCESS; irp->IoStatus.Information = request->Status; } else{ irp->IoStatus.Status = STATUS_UNSUCCESSFUL; irp->IoStatus.Information = request->Status; } SmartDevFreeBlock(request); IoCompleteRequest(irp, IO_NO_INCREMENT); nPackets++; } } while (nPackets != nPacketsOld); ReleaseLock(&dev->lock);

do { AcquireLock(); b = true; if (*) { ReleaseLock(); b = b ? false : *; } } while ( !b ); ReleaseLock(); do { //get the write lock AcquireLock(&dev->lock); nPacketsOld = nPackets; request = dev->WriteListHeadVa; if( request && request->status ){ dev->WriteListHeadVa = request->Next; ReleaseLock(&dev->lock); irp = request->irp; if(request->status > 0){ irp->IoStatus.Status = STATUS_SUCCESS; irp->IoStatus.Information = request->Status; } else{ irp->IoStatus.Status = STATUS_UNSUCCESSFUL; irp->IoStatus.Information = request->Status; } SmartDevFreeBlock(request); IoCompleteRequest(irp, IO_NO_INCREMENT); nPackets++; } } while (nPackets != nPacketsOld); ReleaseLock(&dev->lock); Predicate Abstraction

C program Boolean program Predicate Abstraction (C2bp) Model Checking (Bebop) [PASTE 2001, Spin 2000] Predicate Discovery (Newton) E = {e 1,...,e n } no yes

C2bp: Predicate Abstraction for C Programs Given P : a C program E = {e 1,...,e n } : set of C boolean expressions over the variables in P no side effects, no procedure calls Produce a boolean program B same control-flow structure as P only vars are 3-valued booleans {b 1,...,b n } properties true of B are true of P

Contributions C2bp handles the constructs of C pointers, recursion, structs, casts modular abstraction of procedures provably sound successfully applied to verify properties of device drivers

C2bp Algorithm operates on intermediate representation contains only assignments, conditionals, procedure calls, gotos abstracts each statement in isolation no control-flow analysis no need for loop invariants

Abstracting Assignments replace assn statement s with a parallel assignment to boolean vars in scope: predicate e i is true after s iff wp(s, e i ) is true before s b i = wp(s, e i ) ; example: wp( y=y+1, x==y) = (x==y)[y+1/y] = (x==y+1) but wp(s, e i ) may not be expressible in terms of {e 1,...,e n }...

Strengthening S(e) is the best predicate over {e 1,...,e n } that implies e: a minterm is a conjunction d 1 ^... ^ d n, where d i = e i or d i = !e i S(e) = disjunction of all minterms that imply e use decision procedure to check implication

Abstracting Assignments S(wp(s, e i )) is true before s implies predicate e i is true after s S(!wp(s, e i )) is true before s implies predicate e i is false after s b i = S(wp(s, e i )) ? true : S(!wp(s, e i )) ? false : *;

Assignment Example Statement in P: Predicates in E: y = y+1; {x==y} Weakest Precondition: wp( y=y+1, x==y) = x==y+1 Strengthenings: S(x==y+1) = falseS(x!=y+1)) = x==y Abstraction of s in B: b = b ? false : *;

Handling Pointers Weakest Precondition: wp( *p=3, x==5) = x==5 What if *p and x alias? We use Das’s pointer analysis [PLDI 2000] to prune disjuncts representing infeasible alias scenarios. Correct Weakest Precondition: (p==&x && 3==5) || (p!=&x && x==5) Statement in P:Predicates in E: *p = 3; {x==5}

Abstracting Conditionals in P: if ( expr ) {...} else {...} in B: if (*) {assume( W(expr) );...} else {assume( W(!expr) );...} weakening : W(expr) = !S(!expr)

Handling Procedures each predicate in E is annotated as being either global or local to a particular procedure procedures abstracted in two passes: a signature is produced for each procedure in isolation procedure calls are abstracted given the callees’ signatures

Formal Properties soundness [Ball, Millstein & Rajamani, MSR-TR] B has a superset of the feasible paths in P b i is true (false) at some point on a path in B implies e i is true (false) at that point along a corresponding path in P complexity linear in size of program flow analysis deferred to the model checker exponential in number of predicates

Experience checked several device drivers for proper usage of locks proper handling of interrupt request packets (IRPs) verified four drivers from the Windows 2000 Driver Development Kit found a bug in IRP handling in a Microsoft- internal floppy device driver ran C2bp on 6500 LOC with 23 predicates in 98 seconds model checking takes under 10 seconds

Conclusions C2bp, the first automatic predicate abstractor for C code pointers, procedures, recursion provably sound a necessary step for making software model checking a reality useful for other tasks that require predicate sensitivity

Predicate-sensitive Alias Analysis prev = NULL; newl = NULL; while (curr) { next = curr->next; if (curr->val > v) { if (prev) prev->next = next; curr->next = newl; L: newl = curr; } else prev = curr; curr = nextCurr; } prev == NULL curr == NULL prev->val > v curr->val > v (curr!=NULL) && ( prev==NULL || (prev->val val >v) ) implies (prev != curr) at label L