CHECKING MEMORY SAFETY AND TEST GENERATION USING B LAST By: Pashootan Vaezipoor Computing Science Dept of Simon Fraser University.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Linked Lists CSE 2451 Matt Boggus. Dynamic memory reminder Allocate memory during run-time malloc() and calloc() – return a void pointer to memory or.
Carnegie Mellon 1 Dynamic Memory Allocation: Basic Concepts : Introduction to Computer Systems 17 th Lecture, Oct. 21, 2010 Instructors: Randy Bryant.
1 Chapter 8: Code Generation. 2 Generating Instructions from Three-address Code Example: D = (A*B)+C =* A B T1 =+ T1 C T2 = T2 D.
Dynamic Memory Allocation (also see pointers lectures) -L. Grewe.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
By Dirk Beyer, Alessandro Cimatti, Alberto Griggio, Erkan Keremoglu and Roberto Sebastiani Simon Fraser University (Spring 09) Presentation By: Pashootan.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
Concolic Modularity Testing Derrick Coetzee University of California, Berkeley CS 265 Final Project Presentation.
Debugging Introduction to Computing Science and Programming I.
Korey Breshears. Overview  What are automated security tools?  Why do we need them?  What types of tools are there?  What problems do these tools.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Type-Safe Programming in C George Necula EECS Department University of California, Berkeley.
Proof-system search ( ` ) Interpretation search ( ² ) Main search strategy DPLL Backtracking Incremental SAT Natural deduction Sequents Resolution Main.
Fast Effective Dynamic Compilation Joel Auslander, Mathai Philipose, Craig Chambers, etc. PLDI’96 Department of Computer Science and Engineering Univ.
1 TinyOS 2.1: Deploying Memory Safety Nathan Cooprider Yang Chen Will Archer Eric Eide David Gay † John Regehr University of Utah School of Computing †
Template class Wrapper { public: T* operator->() { return &myT; } private: T myT; }; int main() { Wrapper wThing; wThing- >Foo(); // calls Thing::Foo()...
1 Efficient Memory Safety for TinyOS 2.1 Yang Chen Nathan Cooprider Will Archer Eric Eide David Gay † John Regehr University of Utah School of Computing.
1 ES 314 Advanced Programming Lec 3 Sept 8 Goals: complete discussion of pointers discuss 1-d array examples Selection sorting Insertion sorting 2-d arrays.
Run-Time Error Handling Wes Weimer, George Necula.
Insertion into a B+ Tree Null Tree Ptr Data Pointer * Tree Node Ptr After Adding 8 and then 5… 85 Insert 1 : causes overflow – add a new level * 5 * 158.
. Memory Management. Memory Organization u During run time, variables can be stored in one of three “pools”  Stack  Static heap  Dynamic heap.
Advanced Topics in Algorithms and Data Structures 1 Two parallel list ranking algorithms An O (log n ) time and O ( n log n ) work list ranking algorithm.
1 The Problem o Fluid software cannot be trusted to behave as advertised unknown origin (must be assumed to be malicious) known origin (can be erroneous.
May 22, 2002OSQ Retreat 1 CCured: Taming C Pointers George Necula Scott McPeak Wes Weimer
Checking Memory Safety with BLAST Dirk Beyer, et al. FASE 2005 KAIST CS750b 2006 Fall Seonggun Kim.
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
By D. Beyer et. al. Simon Fraser University (Spring 09) Presentation By: Pashootan Vaezipoor.
Overview Working directly with memory locations is beneficial. In C, pointers allow you to: change values passed as arguments to functions work directly.
Language Evaluation Criteria
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.
By: Pashootan Vaezipoor Path Invariant Simon Fraser University – Spring 09.
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
15-740/ Oct. 17, 2012 Stefan Muller.  Problem: Software is buggy!  More specific problem: Want to make sure software doesn’t have bad property.
Department of Computer Science A Static Program Analyzer to increase software reuse Ramakrishnan Venkitaraman and Gopal Gupta.
Program Analysis with Dynamic Change of Precision Dirk Beyer Tom Henzinger Grégory Théoduloz Presented by: Pashootan Vaezipoor Directed Reading ASE 2008.
1 Efficient Type and Memory Safety for Tiny Embedded Systems John Regehr Nathan Cooprider Will Archer Eric Eide University of Utah School of Computing.
Pointers review Let a variable aa be defined as ‘int *aa;’, what is stored in aa? Let a variable aa be defined as ‘int ** aa;’ what is stored in aa? Why.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 26: Exam 2 Preview.
Week 9 Part 1 Kyle Dewey. Overview Dynamic allocation continued Heap versus stack Memory-related bugs Exam #2.
3/8/2007 Copyright (c) 2007 by Adcock, Bucci, Heym, Hollingsworth, Long, & Weide 1 Which Pointer Errors Do Students Make? Bruce Adcock 1 Paolo Bucci 1.
Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Dynamic Memory Allocation Suppose we defined the data type: struct custrec.
Reasoning about programs March CSE 403, Winter 2011, Brun.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
A local search algorithm with repair procedure for the Roadef 2010 challenge Lauri Ahlroth, André Schumacher, Henri Tokola
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Pointers.
5.01 Understand Different Types of Programming Errors
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
LINKED LISTS.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Dr. Hussien Sharaf Dr Emad Nabil. Dr. Hussien M. Sharaf 2 position := initial + rate * Lexical analyzer 2. Syntax analyzer id 1 := id 2 + id 3 *
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
CSE 220 – C Programming malloc, calloc, realloc.
Object Lifetime and Pointers
5.01 Understand Different Types of Programming Errors
Pointers & Dynamic Memory
Safe TinyOS.
Dynamic Memory CSCE 121 J. Michael Moore.
5.01 Understand Different Types of Programming Errors
CETS: Compiler-Enforced Temporal Safety for C
See requirements for practice program on next slide.
WJEC GCSE Computer Science
SOFTWARE ENGINEERING INSTITUTE
Presentation transcript:

CHECKING MEMORY SAFETY AND TEST GENERATION USING B LAST By: Pashootan Vaezipoor Computing Science Dept of Simon Fraser University

Memory Safety A program is memory safe if: Only accesses objects it has allocated Or the ones that it has been granted access Null pointer dereferencing is an aspect of memory safety Meaning that we shall not access a null variable in our program

Example In this code, the programmer has instrumented the program to check ptr to see if it is null We want to do this instrumentation automatically! This way, we are reducing the memory safety problem to a reachability problem

Possible Strategies Strategy #1: Annotate all memory accesses Run Blast on the result Check if it violates We can do it much easier using a type-based approach Each annotation should be checked independently Strategy #2: Use Ccured to insert the optimized runtime checks Use Blast to remove some of the remaining checks Ccured optimisation removes 50% of checks The output program runs 2 times slower than the original one

Technical Issues CCured adds a call to the __CHECK_NULL(p) for each unsafe pointer access Blast replaces __CHECK_NULL(p) with __BLAST_CHECK_NULL(p) Blast checks if the __BLAST_ERROR is reachable Outcomes: Not reachable: remove the call Reachable: Error path is created Check must remain The error might be a simple program bug ( malloc ) Blast fails: Check must remain

Experiments

Test Generation Consider the following example that tries to find the middle of three values, along with its CFA:

Example The task of finding a test vector for a program location consists of these steps: Model Checking: First we check for locations reachability Blast makes the path in the ART In the Example: m=z;assume(y<z);assume(x<y) Tests from counterexamples: Build the path formula m=z ^ y<z ^ x<y Find the satisfying assignment for the formula X=0, y=1, z=2, m=2

Example Since the path to L5 is feasible, the PF is satisfiable We have to repeat this task for all locations in the program to find the location coverage of the program We have some of the vectors here, but L13 and L15 are not covered (hence unreachable)

B LAST Test Framework A test framework comprises the followings: Suitable program representation CFA Test vector representation A vector of values for initial variables and functions return values and program input An adequacy criterion A test generation procedure Test driver

B LAST Test Framework (Coverage Goals) Test adequacy criterion is a set of coverage goals that determine when the program has been tested thoroughly We do that using target predicate coverage

Test suit Generation The model checking algorithm takes as input a set of CFAs and a conguration (q, p) of target location and target predicate Algorithm returns either with outcome O1: a complete ART T that is safe w.r.t. (q, p) O2: a path from the root node to a node n : (q, ·, ϕ ) such that ϕ p is satisable

Steps of the Test Generator Step 1: The CFA locations are numbered in DFS order and put in a worklist Step 2: If the worklist is empty, we are done Else we invoke the Model checker with current ART and the config (q, p) Step 3: Outcome O 1 : No Test Vectors exist Outcome O2: We have found a p-reachable location q (use it for test generation)

Example The DFS order for the middle is like this:

Experiment Results