Software safety - DEF-STAN 00-55

Similar documents
Formal Verification by Model Checking

Static Program Transformations for Efficient Software Model Checking

Model Checking: An Introduction

Model Checking for Software

Model Checking of Software

NASA s State-Space Exploration: Verifying Safety-Critical Systems

Coverability for Parallel Programs

Towards a Framework for Generating Tests to Satisfy Complex Code Coverage in Java Pathfinder

A Logic Approach for LTL System Modification

The Model Checker SPIN

Today s Agenda. Automata and Logic. Quiz 4 Temporal Logic. Introduction Buchi Automata Linear Time Logic Summary

Lecture 9 verifying temporal logic

Testing LTL Formula Translation into Büchi Automata

Introduction to Software Verification

Automated Detection of Non-Termination and NullPointerExceptions for Java Bytecode

tutorial: hardware and software model checking

Model Checking based Software Verification

Applying Model Checking in Java Verification

Handout #1: Mathematical Reasoning

Formal Verification of Software

Temporal Logics. Computation Tree Logic

Fundamentals of Software Engineering

Building SMT-based Software Model Checkers: an Experience Report

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Software Modeling and Verification

Journal of Mathematics Volume 1, Number 1, Summer 2006 pp

Grigore Rosu Founder, President and CEO Professor of Computer Science, University of Illinois

Algorithmic Software Verification

A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation

Verifying Multi-Agent Programs by Model Checking

An Overview of the Runtime Verification Tool Java PathExplorer

Formal verification of contracts for synchronous software components using NuSMV

VeriTech - A Framework for Translating among Model Description Notations

logic language, static/dynamic models SAT solvers Verified Software Systems 1 How can we model check of a program or system?

Automated Theorem Proving - summary of lecture 1

Application of Design for Verification with Concurrency Controllers to Air Traffic Control Software

Introduction to SPIN. Acknowledgments. Parts of the slides are based on an earlier lecture by Radu Iosif, Verimag. Ralf Huuck. Features PROMELA/SPIN

02 B The Java Virtual Machine

Fabio Patrizi DIS Sapienza - University of Rome

The Course.

Software Engineering using Formal Methods

Formal Verification and Linear-time Model Checking

InvGen: An Efficient Invariant Generator

University of Twente. A simulation of the Java Virtual Machine using graph grammars

Validated Templates for Specification of Complex LTL Formulas

Synthesizing Monitors for Safety Properties

Introduction to Static Analysis for Assurance

Trace Server: A Tool for Storing, Querying and Analyzing Execution Traces

Development of dynamically evolving and self-adaptive software. 1. Background

Aachen. Model Checking of Software for Microcontrollers. Department of Computer Science. Technical Report. Bastian Schlich

The Software Model Checker BLAST: Applications to Software Engineering

CORRECTNESS of computer systems is critical in today s

Using Patterns and Composite Propositions to Automate the Generation of Complex LTL

Specification and Analysis of Contracts Lecture 1 Introduction

How To Develop A Static Analysis System For Large Programs

Towards Verification of MPJ-based Java Programs

The software model checker BLAST

Model Checking II Temporal Logic Model Checking

Model checking test models. Author: Kevin de Berk Supervisors: Prof. dr. Wan Fokkink, dr. ir. Machiel van der Bijl

T Reactive Systems: Introduction and Finite State Automata

Software Active Online Monitoring Under. Anticipatory Semantics

Summary of Dagstuhl Seminar on Directed Model Checking

Quick Start Guide. June 3, 2012

Rigorous Software Engineering Hoare Logic and Design by Contracts

Tr ends in Software Verification

Formal Verification Toolkit for Requirements and Early Design Stages

Model-Checking Verification for Reliable Web Service

Teaching Software Model Checking

Monitoring Programs using Rewriting

MODEL CHECKING OF SERVICES WORKFLOW RECONFIGURATION: A PERSPECTIVE ON DEPENDABILITY

Toward Automated Detection of Logic Vulnerabilities in Web Applications

An Approach to Dependable Embedded Software Development

Software Verification: Infinite-State Model Checking and Static Program

Concurrent Software Verification with States, Events, and Deadlocks 1,2

The Eighth International Conference INCOSE_IL Formal Methods Security Tools in the Service of Cyber Security

The ProB Animator and Model Checker for B

Problem Sheet 9: Software Model Checking Sample Solutions

Optimizing Generation of Object Graphs in Java PathFinder

Reasoning about Safety Critical Java

CHAPTER 7 GENERAL PROOF SYSTEMS

Traditional Software Development. Model Requirements and JAVA Programs. Formal Verification & Validation. What is a state?

Software Verification for Space Applications Part 2. Autonomous Systems. G. Brat USRA/RIACS

General Introduction

HOTPATH VM. An Effective JIT Compiler for Resource-constrained Devices

Automated Domain-Specific C Verification with mbeddr

An Automated Verification Method for Distributed Systems Software Based on Model Extraction

CMSC 858T: Randomized Algorithms Spring 2003 Handout 8: The Local Lemma

Abstract Model Checking of Web Applications Using Java PathFinder

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Software Quality Exercise 1

LTL Model Checking with Logic Based Petri Nets

Security Analysis of Role-based Access Control through Program Verification

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

Model Checking Distributed Software

Regression Verification: Status Report

Code Generation for High-Assurance Java Card Applets

2 Temporal Logic Model Checking

Applications of obfuscation to software and hardware systems

Software Model Checking: Theory and Practice

MEMORY MODEL SENSITIVE ANALYSIS OF CONCURRENT DATA TYPES. Sebastian Burckhardt. Computer and Information Science

Transcription:

Software safety - DEF-STAN 00-55 Where safety is dependent on the safety related software (SRS) fully meeting its requirements, demonstrating safety is equivalent to demonstrating correctness with respect to the Software Requirement. Ultimate problems addressable by model checking Checking correctness of the code running on the application - Two main approaches: Code Model Checking (Software Model Checking) Model Based Development Checking safety of the system (the system never runs into an unsafe state) Concentrating on safety properties on a Model of the system Opening to probabilistic safety

Software Model Checking Although the early papers on model checking focused on software, not many applications to prove the correctness of code, until 1997 Until 1997 most work was on software designs Finding bugs early is more cost-effective Reality is that people write code first, rather than design Only later the harder problem of analyzing actual source code was first attempted Pioneering work at NASA Software Model Checking Most model checkers cannot directly deal with the features of modern programming languages Bringing programs to model checking Translation to a standard Model Checker Bringing model checking to programs Ad hoc model checkers that directly deal with programs as input In both cases, need of Abstraction.

Willem Visser 2002 Abstraction Program void add(object o) { buffer[head] = o; head = (head+1)%size; } Model Checker Input Object take() { tail=(tail+1)%size; return buffer[tail]; } Possibly infinite state Finite state Abstraction Model checkers don t take real programs as input Model checkers typically work on finite state systems Abstraction cuts the state space size to something manageable Abstraction eliminates details irrelevant to the property Disadvantage: Loss of Precision: False positives/negatives Abstraction comes in three flavors Over-approximations, i.e. more behaviors are added to the abstracted system than are present in the original Under-approximations, i.e. less behaviors are present in the abstracted system than are present in the original Precise abstractions, i.e. the same behaviors are present in the abstracted and original program

Under-Approximation Meat-Axe Abstraction Remove parts of the program considered irrelevant for the property being checked, e.g. Limit input values to 0..10 rather than all integer values Queue size 3 instead of unbounded, etc. The abstraction of choice in the early applications of software model checking Used during the translation of code to a model checker s input language Typically manual, no guarantee that only the irrelevant behaviors are removed. Willem Visser 2002 Precise abstraction Precise abstraction, w.r.t. the property being checked, may be obtained if the behaviors being removed are indeed not influencing the property Program slicing is an example of an automated under-approximation that will lead to a precise abstraction w.r.t. the property being checked indirectly relevant Property-directed Slicing Slice mentioned in property Source program Resulting slice slicing criterion generated automatically from observables mentioned in the property backwards slicing automatically finds all components that might influence the observables.

Over-Approximations Abstract Interpretation Maps sets of states in the concrete program to one state in the abstract program Reduces the number of states, but increases the number of possible transitions, and hence the number of behaviors Can in rare cases lead to a precise abstraction Type-based abstractions (-->) Predicate abstraction (-->) Automated (conservative) abstraction Problem: Eliminating spurious errors Abstract program has more behaviors, therefore when an error is found in the abstract program, is that also an error in the original program? Data Type Abstraction Abstraction homomorphism h: int --> Sign Replace int by Sign abstraction {neg,pos,zero} NEG if x<0 h(x) = ZERO if x =0 POS if x>0 Code int x = 0; if (x == 0) x = x + 1; h Abstract Interpretation Sign x = ZERO; if (Sign.eq(x,ZERO)) x = Sign.add(x,POS);

Predicate Abstraction Willem Visser 2002 Replace predicates in the program by boolean variables, and replace each instruction that modifies the predicate with a corresponding instruction that modifies the boolean. Abstract T F EQ = T EQ := F EQ = F " : int # int bool EQ $ (x = y) EQ $ (x = y) Concrete x = y x! y x = 0 y = 0 y++ x = 0 y = 1 Mapping of a concrete system to an abstract system, whose states correspond to truth values of a set of predicate Create abstract state-graph during model checking, or, Create an abstract transition system before model checking How do we Abstract Behaviors? Abstract domain A Abstract concrete values to those in A Then compute transitions in the abstract domain Over-approximations: Add extra behaviors Under-approximations: Remove actual behaviors

Underlying model: Kripke Structures M = (S,s 0,%>,L) on AP! S: Set of States! s 0 : Initial State! ->: Transition Relation! L: S -> 2 AP, Labeling on States Simulations on Kripke Structures M = (S, s 0, ->, L) M = (S, s 0, ->, L ) Definition: R & S # S is a simulation relation between M and M iff (s,s ) ' R implies 1. L(s) = L (s ) 2. for all t s.t. s ( t, exists t s.t. s ( t and (t,t ) ' R. M simulates M (M ~ M ) iff (s 0, t 0 ) ' R Intuitively, every transition in M can be matched by some transition in M

Preservation of properties by the Abstraction M concrete model, M abstract model Strong Preservation: M = P iff M = P Weak Preservation: M = P => M = P Simulation preserves ACTL* properties If M ~ M then M = AG p => M = AG p Abstraction Homomorphisms Concrete States S, Abstract states S Abstraction function (Homomorphism) h: S -> S Induces a partition on S equal to size of S Existential Abstraction - Over-Approximation Make a transition from an abstract state if at least one corresponding concrete state has the transition. Abstract model M simulates concrete model M Universal Abstraction - Under-Approximation Make a transition from an abstract state if all the corresponding concrete states have the transition.

Existential Abstraction - Preservation Let ) be a Universally quantified formula (es, an ACTL* property) M existentially abstracts M, so M ~ M Preservation Theorem Converse does not hold M = ) ( M = ) M = ) ( M = ) M = ) : counterexample may be spurious NOTE: ACTL* is the universal fragment of CTL* Universal Abstraction - Preservation Let ) be a existential-quantified property (i.e., expressed in ECTL*) and M simulates M Preservation Theorem M = ) ( M = ) Converse does not hold M = f ( M = f NOTE: ECTL* is the universal fragment of CTL*

Model Checking (safety) I = unsafe state AG ~ unsafe (true property) Abstraction: Under-Approximation I AG ~ unsafe true (but it is not preserved)

Abstraction: Over-Approximation I It is not a path in the concrete system AG ~ unsafe false spurious counterexample Refinement of the abstraction : I Separate states that are the reason of the spurious counterexample AG ~ unsafe true

Automated Abstraction/Refinement Counterexample-Guided AR (CEGAR) Build an abstract model M Model check property P, M = P? If M = P, then M = P by Preservation Theorem Otherwise, check if Counterexample (CE) is spurious Refine abstract state space using CE analysis results Repeat M := abstract(m) T No Bug M = P F F spurious(ce) Bug T M := refine(m ) Hand-Translation Early applications at NASA Willem Visser 2002 Remote Agent Havelund,Penix,Lowry 1997 http://ase.arc.nasa.gov/havelund Translation from Lisp to Promela (most effort) Heavy abstraction 3 man months DEOS Penix, Visser, et al. 1998/1999 http://ase.arc.nasa.gov/visser C++ to Promela (most effort in environment generation) Limited abstraction - programmers produced sliced system 3 man months

Willem Visser 2002 Semi-Automatic Translation Table-driven translation and abstraction Feaver system by Gerard Holzmann User specifies code fragments in C and how to translate them to Promela (SPIN) Translation is then automatic Found 75 errors in Lucent s PathStar system http://cm.bell-labs.com/cm/cs/who/gerard/ Advantages Can be reused when program changes Works well for programs with long development and only local changes Willem Visser 2002 Fully Automatic Translation Advantage No human intervention required Disadvantage Limited by capabilities of target system Examples Java PathFinder 1- http://ase.arc.nasa.gov/havelund/jpf.html Translates from Java to Promela (Spin) JCAT - http://www.dai-arc.polito.it/dai-arc/auto/tools/tool6.shtml Translates from Java to Promela (or dspin) Bandera - http://www.cis.ksu.edu/santos/bandera/ Translates from Java bytecode to Promela, SMV or dspin

Bringing Model Checking to Programs Allow model checkers to take programming languages as input, (or notations of similar expressive power) Major problem: how to encode the state of the system efficiently Alternatively state-less model checking No state encoding or storing On the fly model checking Almost exclusively explicit-state model checking Abstraction can still be used as well Source to source abstractions Custom-made Model Checkers Translation based dspin Spin extended with dynamic constructs Essentially a C model checker Source-2-source abstractions can be supported http://www.dai-arc.polito.it/dai-arc/auto/tools/tool7.shtml SPIN Version 4 PROMELA language augmented with C code Table-driven abstractions Bandera Translated Bandera Intermediate Language (BIR) to a number of back-end model checkers, but, a new BIR custommade model checker is under development Supports source-2-source abstractions as well as propertyspecific slicing http://www.cis.ksu.edu/santos/bandera/

Willem Visser 2002 Custom-made Model Checkers Abstraction based SLAM C programs are abstracted via predicate abstraction to boolean programs for model checking http://research.microsoft.com/slam/ BLAST Similar basic idea to SLAM, but using lazy abstraction, i.e. during abstraction refinement don t abstract the whole program only certain parts http://www-cad.eecs.berkeley.edu/~tah/blast/ 3-Valued Model Checker (3VMC) extension of TVLA for Java programs http://www.cs.tau.ac.il/~yahave/3vmc.htm http://www.math.tau.ac.il/~rumster/tvla/ Willem Visser 2002 Java Code Java PathFinder (JPF) Bytecode void add(object o) { buffer[head] = o; head = (head+1)%size; } Object take() { tail=(tail+1)%size; return buffer[tail]; } JAVAC 0: iconst_0 1: istore_2 2: goto #39 5: getstatic 8: aload_0 9: iload_2 10: aaload JVM Model Checker Special JVM

Willem Visser 2002 Bandera & JPF Architecture Property Tool Analyses Abstraction Engine BIRC BIR Translators SPIN Java Jimple (BC) dspin Parser SMV Error Trace Display Slicer Simulator Decompile ; javac JPF Willem Visser 2002 One Case Study at NASA: DS-1 Remote Agent Commands Spacecraft Tasks Subscribe Property Locks Achieve Property Sensors Data base Interrupt Properties Monitor Lock Event Change Event Several person-months to create verification model. One person-week to run verification studies.

Willem Visser 2002 One Case Study at NASA: DS-1 Remote Agent Monitor Logic DB change? Unexpected timing of change event yes no check wait Five difficult to find concurrency errors detected [Model Checking] has had a substantial impact, helping the RA team improve the quality of the Executive well beyond what would otherwise have been produced. - RA team During flight RA deadlocked (in code we didn t analyze) Found this deadlock with JPF Model Based Development Pioneering work at NASA has concentrated on Software Model Checking, that is, work on software as it is, maybe provided by a third party. In a large part of the safety-critical systems industry, the Model Based Design approach has emerged as the main paradigm for the development of software.

Model - Based Development Manual coding Modelization Phase Software Requirements Document (Finite State) Model Test Suite Test Case Definition Natural Language Formalized Architectural Design Detailed Design Architectural Design Document Detailed Design Document Coding Source code Integration Test Unit Test Functional test Model - Based Development Manual coding Modelization Phase Software Requirements Document Formalization Phase Formal Verification Properties (formal expr. of Requirements) Test Case Generation Natural Language Formalized Architectural Design Detailed Design (Finite State) Model Architectural Design Document Detailed Design Document Coding Source code Model Checking Integration Test Unit Test Test Suite Functional test

Model - Based Development Automatic coding Modelization Phase Software Requirements Document Test Case Definition (Finite State) Model Test Suite Natural Language Formalized Code Generation Source code Functional test Model - Based Development Automatic coding Modelization Phase Software Requirements Document Formalization Phase Formal Verification Properties (formal expr. of Requirements) Test Case Generation (Finite State) Model Model Checking Test Suite Natural Language Formalized Code Generation Source code Functional test

GETS model based development cycle Verification by Design Verifier use of MC still limited: model validation conducted mostly by simulation/testing Credits Willem Visser. ASE 2002 Tutorial on Software Model Checking Nishant Sinha. Lectures on Abstraction in Model Checking (ppt), 15817, Mar 2005.