Department of Software Engineering Faculty of Mathematics and Physics CHARLES UNIVERSITY IN PRAGUE Czech Republic Extracting Zing Models from C Source.

Slides:



Advertisements
Similar presentations
Translation-Based Compositional Reasoning for Software Systems Fei Xie and James C. Browne Robert P. Kurshan Cadence Design Systems.
Advertisements

Programming Languages and Paradigms
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
A Randomized Dynamic Program Analysis for Detecting Real Deadlocks Koushik Sen CS 265.
1 Symbolic Execution for Model Checking and Testing Corina Păsăreanu (Kestrel) Joint work with Sarfraz Khurshid (MIT) and Willem Visser (RIACS)
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
1 Thorough Static Analysis of Device Drivers Byron Cook – Microsoft Research Joint work with: Tom Ball, Vladimir Levin, Jakob Lichtenberg,
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
SEERE Workshop, Neum Tempura Retargeting Damyan Mitev, Vladimir Valkanov Plovdiv University “Paisii Hilendarski”
Architecture-driven Modeling and Analysis By David Garlan and Bradley Schmerl Presented by Charita Feldman.
ISBN Chapter 6 Data Types: Structured types.
Developing Verifiable Concurrent Software Tevfik Bultan Department of Computer Science University of California, Santa Barbara
Programming Language Semantics Java Threads and Locks Informal Introduction The Java Specification Language Chapter 17.
Synthesis of Interface Specifications for Java Classes Rajeev Alur University of Pennsylvania Joint work with P. Cerny, G. Gupta, P. Madhusudan, W. Nam,
Elementary Data Types Scalar Data Types Numerical Data Types Other
1 Type Type system for a programming language = –set of types AND – rules that specify how a typed program is allowed to behave Why? –to generate better.
Object Oriented Databases - Overview
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Methods For The Prevention, Detection And Removal Of Software Security Vulnerabilities Jay-Evan J. Tevis Department of Computer Science and Software Engineering.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Cs205: engineering software university of virginia fall 2006 Semantics and Specifying Procedures David Evans
CSC2108 Lazy Abstraction on Software Model Checking Wai Sum Mong.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Control Flow Resolution in Dynamic Language Author: Štěpán Šindelář Supervisor: Filip Zavoral, Ph.D.
Model-based Kernel Testing for Concurrency Bugs through Counter Example Replay Moonzoo Kim, Shin Hong, Changki Hong Provable Software Lab. CS Dept. KAIST,
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Names Variables Type Checking Strong Typing Type Compatibility 1.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
1162 JDK 5.0 Features Christian Kemper Principal Architect Borland.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Data Structure & File Systems Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
CMSC 2021 CMSC 202 Computer Science II for Majors Fall 2002 Mr. Frey (0101 – 0104) Mr. Raouf (0201 – 0204)
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
Static Program Analyses of DSP Software Systems Ramakrishnan Venkitaraman and Gopal Gupta.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
CASE/Re-factoring and program slicing
CMSC 2021 CMSC 202 Computer Science II for Majors Spring 2002 Sections Ms. Susan Mitchell.
Findbugs Tin Bui-Huy September, Content What is bug? What is bug? What is Findbugs? What is Findbugs? How to use Findbugs? How to use Findbugs?
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
CMSC 2021 CMSC 202 Computer Science II for Majors Spring 2003 Mr. Frey (0101 – 0104) Mr. Raouf (0201 – 0204)
C H A P T E R T H R E E Type Systems and Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
SystemC Semantics by Actors and Reduction Techniques in Model Checking Marjan Sirjani Formal Methods Lab, ECE Dept. University of Tehran, Iran MoCC 2008.
From Use Cases to Implementation 1. Structural and Behavioral Aspects of Collaborations  Two aspects of Collaborations Structural – specifies the static.
T imed Languages for Embedded Software Ethan Jackson Advisor: Dr. Janos Szitpanovits Institute for Software Integrated Systems Vanderbilt University.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
From Use Cases to Implementation 1. Mapping Requirements Directly to Design and Code  For many, if not most, of our requirements it is relatively easy.
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
Memory Management in Java Mr. Gerb Computer Science 4.
©2004 Joel Jones 1 CS 403: Programming Languages Lecture 3 Fall 2004 Department of Computer Science University of Alabama Joel Jones.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
C++ for Engineers and Scientists Second Edition Chapter 12 Pointers.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Data Types In Text: Chapter 6.
Chapter 6 – Data Types CSCE 343.
Top 50 Data Structures Interview Questions
Semantic Analysis with Emphasis on Name Analysis
C Basics.
Chapter 4: Threads.
A Refinement Calculus for Promela
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
From Use Cases to Implementation
Presentation transcript:

Department of Software Engineering Faculty of Mathematics and Physics CHARLES UNIVERSITY IN PRAGUE Czech Republic Extracting Zing Models from C Source Code Tomáš Matoušek, Filip Zavoral

2 Goals Verification of Windows kernel drivers against rules imposed by the kernel Motivation  Drivers are difficult to test Bugs can appear only at special conditions  Incorrect behavior in cooperation with the environment The kernel is complex and concurrent Technique - model checking  A specification of the kernel API provided to drivers  A model of the driver  Using Zing Model Checker tool

3 Our Previous Work: Kernel Specifications DeSpec  Driver Environment Specification Language  An object-oriented specification and modeling language  Allows to abstract and model kernel API functions and structures model the kernel’s behavior to drivers capture various constrains imposed on the driver

4 DeSpec Example class DEVICE_OBJECT { NTSTATUS IoAttachDevice(instance, object! targetName, out DEVICE_OBJECT attached) requires !Driver.IsLowest; requires thread.Irql == KIRQL.PASSIVE_LEVEL; { result = choose { NTSTATUS.STATUS_SUCCESS, NTSTATUS.STATUS_INSUF_RESOURCES }; attached = IsSuccessful(result) ? Driver.LowerDevice : null; } void IoDetachDevice(instance) requires thread.Irql == KIRQL.PASSIVE_LEVEL; static rule forall(DEVICE_OBJECT device) { _.IoAttachDevice(..., out device)::succeeded } corresponds to { device.IoDetachDevice() } globally; }

Zing Example class Fork { Philosopher holder; void PickUp(Philosopher eater) { atomic { select { wait(holder == null) -> holder = eater; } void PutDown() { holder = null; } }; class Philosopher { Fork leftFork; Fork rightFork; void Run() { while (true) { leftFork.PickUp(this); rightFork.PickUp(this); leftFork.PutDown(); rightFork.PutDown(); } };

6 Model Extractor Implementation Inputs  Source code of the driver (C language)  Specification of the kernel environment (DeSpec)  Set of rules to be verified (DeSpec) Process  C code parsing, merging and analysis  Extraction of Zing model from driver source code  Combination of the extracted model with the kernel model  Zing model slicing Output  Zing model realizing driver’s interactions with the environment  Passed to Zing model checker

7 Modeling C Language Constructs in Zing Zing  Object-oriented modeling language  Some C constructs cannot be mapped directly  Major issues: pointers, arrays, pointer arithmetic Modeling types  Primitive (int, …) string literal: static array of int  Composite (struct, union) dynamically allocated value types boxed  Static arrays  Data pointers  Function pointers

Modeling Variables Address-may-be-taken flag Variable models  Value int, float, struct, pointer, address never taken non-pointer types: mapped directly data pointers: special methods  DerefGet, DerefSet, AddIntPtr, SubPtrPtr, CmpPtrPtr Function pointers: integer, indirect call  switch  BoxedValue int, float, struct, pointer, address may be taken Box type  StaticArray static array multidimensional arrays flattened

Pointer Representation Data pointer represented by a pair  4 types of pointer targets  Statically allocated storage Single value Sequence of values – multi-value  Dynamically allocated storage Provably single value Possibly multi-value Potential multi-values  Static analysis  Represented by expandable Zing array

10 Example: Pointers to Dynamically Allocated Memory void* p = malloc(size); int* q = p; q += 3; *q = 5; Data type not known prior the first write operation

Example: Static Single- and Multi-value Pointers int t = 1; int *s = &t; int a[5]; int *u = &a[1]; int *v = a; u[2] = 3; v += 4; *v = 6;

12 Slicing Goal  To reduce size of the resulting model as much as possible  Slicing criterion : variables related to the rules selected for verification Two possibilities  Slice the C program before the extraction More complex Needs to deal with pointers (already done by the extraction)  Slice the extracted Zing program Zing similar to simplified Java Reuse existing work on Java programs slicing We go this way

13 Related Work Model checking  Zing Model Checker (Microsoft Research)  Bogor Model Checking Framework (SAnToS labs)  SPIN (Bell Labs) Driver checking  Static Driver Verifier (Microsoft Research) Model checking based on Boolean programs  Driver Verifier (Microsoft) Run-time checking  PREfast (Microsoft) Static analysis, error patterns searching Java Slicing  JPF, Bogor Framework  Nanda, M. G.: Slicing Concurrent Java Programs

14 Conclusion & Future Work DeSpec language  Specifications of the Windows kernel environment  Formalization of rules defined by Driver Development Kit in plain English  Proof of the concept: A specification of a significant subset of kernel API Model Extractor  Zing model extraction, dealing with C pointers  Proof of the concept (C to Zing extraction w/o model reduction) Synchronized priority queue via singly linked list written in C Intentional errors in implementation revealed in seconds Correct implementation verified in 31 minutes (3 threads, 9 items in the que) Future work  Model Extractor improvements Model size reduction via slicing Tests on real Window kernel drivers

Extracting Zing Models from C Source Code 15 Thank you for your attention