36
Automatically Validating Tempor Safety Properties of Interfaces Thomas Ball, Sriram K. Rajamani @ Presented by Xin Li

Automatically Validating Temporal Safety Properties of Interfaces

  • Upload
    warren

  • View
    37

  • Download
    0

Embed Size (px)

DESCRIPTION

Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball, Sriram K. Rajamani @ MSR. Presented by Xin Li. Outline. Overview. Project Components History. Challenges. Boolean Programs and Rules Example. Abstraction. Model Checking Refinement Complexity - PowerPoint PPT Presentation

Citation preview

Page 1: Automatically Validating Temporal  Safety Properties of Interfaces

Automatically Validating Temporal Safety Properties of Interfaces

Thomas Ball, Sriram K. Rajamani @ MSR

Presented by Xin Li

Page 2: Automatically Validating Temporal  Safety Properties of Interfaces

Outline

OverviewProject ComponentsHistoryChallengesBoolean Programs and RulesExample

AbstractionModel CheckingRefinement

ComplexityConclusion

Page 3: Automatically Validating Temporal  Safety Properties of Interfaces

Source Code

TestingDevelopment

PreciseAPI Usage Rules

(SLIC)

Software Model Checking

Read forunderstanding

New API rules

Drive testingtools

Defects

100% pathcoverage

Rules

Static Driver VerifierStatic Driver Verifier

Page 4: Automatically Validating Temporal  Safety Properties of Interfaces

SDV X

Result

Static Driver Verifier

Rules

SLAM

OS model

driver.h

driver.c

Driver sources

other.h

Page 5: Automatically Validating Temporal  Safety Properties of Interfaces

What is SLAM?

SLAM is a software model checking project@ Microsoft Research MSR

Goal:Check automatically C programs (system software)against safety properties using model checking.Present property violations as error traces in the sourcecode.

Application domain: device drivers

Used internally inside Windows for driver verification.Planned to be released for third-party driver developer.

Page 6: Automatically Validating Temporal  Safety Properties of Interfaces

SLAM – Software Model Checking

Given a safety property to check on a C program P, theSLAM process iteratively refines a boolean programabstraction of P using three tools:

C2bp: predicate abstraction, abstracts P into booleanprogram BP(P,E) with respect of predicates E over P

Bebop: tool for model checking boolean programs,determine if ERROR is reachable in BP(P,E)

Newton: discovers additional predicates to refine booleanprogram by analyzing feasibility of paths in P

Page 7: Automatically Validating Temporal  Safety Properties of Interfaces

SLAM - History

Initial discussions: Thomas Ball, Sriram K. Rajamani @ Microsoft ResearchMSRFirst technical report January 2000Spring 2000

Bebop model checkerSummer 2000

Initial c2bp implementationModel checked a safety property of an NT driverHand instrumented code/predicates discovered by hand

Autumn 2000Predicate discovery (Newton)Checked properties of drivers from DDKHand instrumented code/automatic discovery of predicates

Winter 2000SLIC specification language

Spring 2001Found first real error in production codeTotal automation (manual model specifications)

TACAS 2001: Boolean and Cartesian Abstractions for Model Checking CPrograms, April 2001, Genoa, Italy.

Page 8: Automatically Validating Temporal  Safety Properties of Interfaces

Static Driver Verifier - History

Research Prototype SLAM Production Tool SDV

March 2002Bill Gates Review

Mai 2002Windows committed to hire two Ph.D.s in model checking to supportStatic Driver Verifier

Autumn 2002Joint Project between MSR and WindowsInitial release of SDV 1.0 to Windows (friends and family)(SLAM engine, interface usage rules, kernel model, GUI and scripts)

April 2003wide release of SDV 1.2 to Windows(any internal driver developer)

November 2003SDV 1.3 released at Driver Developer Conference (better integration,more rules, better models)

Since 2004 SDV fully transferred to Windows (6 full-time positions)Public release planned for end of 2004

Page 9: Automatically Validating Temporal  Safety Properties of Interfaces

A Brief History of Microsoft

19801980 19901990 20002000

Ric

hn

ess

Ric

hn

ess

Win16Win16 Win32Win32COMCOM

MFCMFCComponents

ComponentsServicesServices

APIsAPIs

Windows3.0

Page 10: Automatically Validating Temporal  Safety Properties of Interfaces

Bebop Model Checker

Page 11: Automatically Validating Temporal  Safety Properties of Interfaces
Page 12: Automatically Validating Temporal  Safety Properties of Interfaces
Page 13: Automatically Validating Temporal  Safety Properties of Interfaces

Model Checking Challenges

Thousands of lines of code

Recursive procedures

Infinite Control

Infinite Data

SLAM Solutions:Boolean transformation

Predicate Abstraction

Page 14: Automatically Validating Temporal  Safety Properties of Interfaces

Boolean Programs

C program, but only boolean variables

Boolean variables represent finite sets of dataflow facts

All C control-flow primitives (condition, loops, …)

No pointers

Procedures with call-by-value parameter passing

Non-deterministic choice operator *do {

b = true;

if (*){b = b ? false : *;

}} while (!b);

do {deviceNoOld = deviceNo;more = devices->Next;if (more){

deviceNo++;}

} while (deviceNoOld != deviceNo);

Page 15: Automatically Validating Temporal  Safety Properties of Interfaces

SLIC

Low-level specification language

Specifies temporal safety properties/rules

Defines state machine, that monitors behavior of a Cprogram

Atomic propositions of a SLIC specification are booleanfunctions

Suitable for expressing control-dominated propertiese.g. proper sequence of events

can encode data values inside state

Page 16: Automatically Validating Temporal  Safety Properties of Interfaces

abort;} else {

locked=1;}

}

ReleaseLock.call {if (locked==0) {

abort;} else {

locked=0;}

}

Unlocked Locked Error

U

L

L

Usage Rule for LockingState Machine

U

SLIC

int locked = 0;

AcquireLock.call {if (locked==1) {

Page 17: Automatically Validating Temporal  Safety Properties of Interfaces

prog. P’prog. P

SLIC rule

The SLAM Process

boolean program

pathpredicates

slic

c2bp

bebop

newton

Page 18: Automatically Validating Temporal  Safety Properties of Interfaces

B

PIs ERRORreachable?

No, explanation Yes

Return “Yes”, p

Is ERROR reachable?Bebop

Yes, path p No

Return “No”Is p feasible in P?

Newton

C2bpPredicates frominstrumentation

Page 19: Automatically Validating Temporal  Safety Properties of Interfaces

do {KeAcquireSpinLock();

nPacketsOld = nPackets;

if(request){request = request->Next;KeReleaseSpinLock();nPackets++;

}} while (nPackets != nPacketsOld);

KeReleaseSpinLock();

Example

Page 20: Automatically Validating Temporal  Safety Properties of Interfaces

do {KeAcquireSpinLock();

if(*){

KeReleaseSpinLock();

}} while (*);

KeReleaseSpinLock();

Example Model checking boolean program

(bebop)

U

L

L

L

L

U

L

U

U

U

E

Page 21: Automatically Validating Temporal  Safety Properties of Interfaces

do {KeAcquireSpinLock();

nPacketsOld = nPackets;

if(request){request = request->Next;KeReleaseSpinLock();nPackets++;

}} while (nPackets != nPacketsOld);

KeReleaseSpinLock();

Example Is error path feasiblein C program?

(newton)

U

L

L

L

L

U

L

U

U

U

E

Page 22: Automatically Validating Temporal  Safety Properties of Interfaces

do {KeAcquireSpinLock();

nPacketsOld = nPackets; b = true;

if(request){request = request->Next;KeReleaseSpinLock();nPackets++; b = b ? false : *;

}} while (nPackets != nPacketsOld); !b

KeReleaseSpinLock();

Example Add new predicateto boolean program

(c2bp)b : (nPacketsOld == nPackets)

U

L

L

L

L

U

L

U

U

U

E

Page 23: Automatically Validating Temporal  Safety Properties of Interfaces

do {KeAcquireSpinLock();

b = true;

if(*){

KeReleaseSpinLock();b = b ? false : *;

}} while ( !b );

KeReleaseSpinLock();

b

b

b

b

Example Model checking refined

boolean program(bebop)

b : (nPacketsOld == nPackets)

U

L

L

L

L

U

L

U

U

U

E

b

b

!b

Page 24: Automatically Validating Temporal  Safety Properties of Interfaces

Example

do {KeAcquireSpinLock();

b = true;

if(*){

KeReleaseSpinLock();b = b ? false : *;

}} while ( !b );

KeReleaseSpinLock();

b : (nPacketsOld == nPackets)

b

b

b

b

U

L

L

L

L

U

L

U

U

b

b

!b

Model checking refined

boolean program(bebop)

Page 25: Automatically Validating Temporal  Safety Properties of Interfaces

prog. P’prog. P

SLIC rule

The SLAM Process

boolean program

pathpredicates

slic

c2bp

bebop

newton

Page 26: Automatically Validating Temporal  Safety Properties of Interfaces

c2bp: Predicate Abstraction for C ProgramsGiven P : a C program E = {e1,...,en}

each ei a pure boolean expression each ei represents set of states for which ei is true

Produce a boolean program B(P,E) same control-flow structure as P boolean vars {b1,...,bn} to match {e1,...,en} properties true of B(P,F) are true of P

Page 27: Automatically Validating Temporal  Safety Properties of Interfaces

C2bp Algorithm

Performs modular abstractionabstracts each procedure in isolation

Within each procedure, abstracts each statement in isolationno control-flow analysisno need for loop invariants

Page 28: Automatically Validating Temporal  Safety Properties of Interfaces

prog. P’prog. P

SLIC rule

The SLAM Process

boolean program

pathpredicates

slic

c2bp

bebop

newton

Page 29: Automatically Validating Temporal  Safety Properties of Interfaces

Bebop Model checker for boolean programs

Based on CFL(context-free language) reachability[Sharir-Pnueli 81] [Reps-Sagiv-Horwitz 95]

Iterative addition of edges to graph“path edges”: <entry,d1> <v,d2>“summary edges”: <call,d1> <ret,d2>

Page 30: Automatically Validating Temporal  Safety Properties of Interfaces

Bebop: summary

Explicit representation of CFG (control flow graph)

Implicit representation of path edges and summary edges

Generation of hierarchical error traces

Page 31: Automatically Validating Temporal  Safety Properties of Interfaces

prog. P’prog. P

SLIC rule

The SLAM Process

boolean program

pathpredicates

slic

c2bp

bebop

newton

Page 32: Automatically Validating Temporal  Safety Properties of Interfaces

Newton

Given an error path p in boolean program B is p a feasible path of the corresponding C program?

Yes: found an error No: find predicates that explain the infeasibility

uses the same interfaces to the theorem provers as c2bp.

Page 33: Automatically Validating Temporal  Safety Properties of Interfaces

Newton

Execute path symbolically

Check conditions for inconsistency using theorem prover (satisfiability)

After detecting inconsistency: minimize inconsistent conditions traverse dependencies obtain predicates

Page 34: Automatically Validating Temporal  Safety Properties of Interfaces

Complexity

Worst-case run-time complexity of C2bp and Bebop islinear in the size of the program's control flow graph, andexponential in the number of predicates used in theabstraction.

Newton scales linearly with path length.O(|p|), |p|: length of path

Complexity: O(E * 2O(N)

)E is the size of the CFG (control flow graph)

N is the max. number of variables in scope

Page 35: Automatically Validating Temporal  Safety Properties of Interfaces

Conclusion

Fully automated methodology

Novel

limitation

Page 36: Automatically Validating Temporal  Safety Properties of Interfaces

ReferencesAutomatically Validating Temporal Safety Properties of Interfaces, Thomas Ball, Sriram K. Rajamani, SPIN 2001, Workshop on Model Checking ofSoftware, LNCS 2057, May 2001, pp. 103-122.Automatically Validating Temporal Safety Properties of Interfaces (Presentation SPIN 2001)Bebop: A Path-sensitive Interprocedural Dataflow Engine, Thomas Ball, Sriram K. Rajamani, PASTE 2001.Bebop: A Path-sensitive Interprocedural Dataflow Engine (Presentation PASTE 2001)Bebop: A Symbolic Model Checker for Boolean Programs, Thomas Ball, Sriram K. Rajamani, SPIN 2000 Workshop on Model Checking of SoftwareLNCS 1885, August/September 2000, pp. 113-130.Bebop: A Symbolic Model Checker for Boolean Programs (Presentation SPIN 2000)Boolean and Cartesian Abstractions for Model Checking C Programs, Thomas Ball, Andreas Podelski, Sriram K. Rajamani, TACAS 2001, LNCS2031, April 2001, pp. 268-283.Boolean and Cartesian Abstraction for Model Checking C Programs (Presentation TACAS 2001)Boolean Programs: A Model and Process for Software Analysis, Thomas Ball, Sriram K. Rajamani, MSR Technical Report 2000-14.Checking Temporal Properties of Software with Boolean Programs, Thomas Ball, Sriram K. Rajamani, Workshop on Advances in Verification (withCAV 2000).From Symptom to Cause: Localizing Errors in Counterexample Traces, Thomas Ball, Mayur Naik, Sriram Rajamani (POPL 2003).From Symptom to Cause: Localizing Errors in Counterexample Traces (Presentation POPL 2003)Generating Abstract Explanations of Spurious Counterexamples in C Programs, Thomas Ball, Sriram K. Rajamani, MSR-TR-2002-09.Parameterized Verification of Multithreaded Software Libraries, Thomas Ball, Sagar Chaki, Sriram K. Rajamani, TACAS 2001,LNCS 2031, April 2001, pp. 158-173.Parameterized Verification of Thread-safe Libraries (Presentation TACAS 2001)Polymorphic Predicate Abstraction, Thomas Ball, Todd Millstein, Sriram K. Rajamani, MSR-TR-2001-10.Refining Approximations in Software Predicate Abstraction, Thomas Ball, Byron Cook, Satyaki Das, Sriram K. Rajamani. TACAS 2004.Relative Completeness of Abstraction Refinement for Software Model Checking, Thomas Ball, Andreas Podelski, Sriram K. Rajamani, TACAS2002, LNCS 2280, April 2002, pp. 158-172.Secrets of Software Model Checking (Presentation SAS 2002)SLIC: A Specification Language for Interface Checking (of C), Thomas Ball, Sriram K. Rajamani, MSR-TR-2001-21.Specifying and Checking Properties of Software (Presentation CSTB's July 2001 Symposium on Fundamentals of Computer Science, July 2001)Speeding Up Dataflow Analysis Using Flow-Insensitive Pointer Analysis, Stephen Adams, Thomas Ball, Manuvir Das, Sorin Lerner, Sriram K.Rajamani, Mark Seigle, Westley Weimer. SAS 2002, LNCS 2477.The SLAM Project: Debugging System Software via Static Analysis, Thomas Ball, Sriram K. Rajamani, POPL 2002, January 2002, pages 1-3.The SLAM Project: Debugging System Software via Static Analysis (Presentation POPL 2002)The SLAM Toolkit, Thomas Ball, Sriram K. Rajamani, CAV 2001.

Thank you!