Generating Tests from Counterexamples Jinseong Jeon ARCS, KAIST.

Slides:



Advertisements
Similar presentations
Masahiro Fujita Yoshihisa Kojima University of Tokyo May 2, 2008
Advertisements

P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Satisfiability Modulo Theories (An introduction)
SCIP Optimization Suite
PLDI’2005Page 1June 2005 Example (C code) int double(int x) { return 2 * x; } void test_me(int x, int y) { int z = double(x); if (z==y) { if (y == x+10)
Architecture-dependent optimizations Functional units, delay slots and dependency analysis.
Some Properties of SSA Mooly Sagiv. Outline Why is it called Static Single Assignment form What does it buy us? How much does it cost us? Open questions.
1 Symbolic Execution for Model Checking and Testing Corina Păsăreanu (Kestrel) Joint work with Sarfraz Khurshid (MIT) and Willem Visser (RIACS)
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
Testing Concurrent/Distributed Systems Review of Final CEN 5076 Class 14 – 12/05.
Symbolic execution © Marcelo d’Amorim 2010.
The Software Model Checker BLAST by Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala and Rupak Majumdar Presented by Yunho Kim Provable Software Lab, KAIST.
Synergy: A New Algorithm for Property Checking
Counter Example Guided Refinement CEGAR Mooly Sagiv.
Recursion CS-240/CS341. What is recursion? a function calls itself –direct recursion a function calls its invoker –indirect recursion f f1 f2.
Finding the Weakest Characterization of Erroneous Inputs Dzintars Avots and Benjamin Livshits.
Branch and Bound Algorithm for Solving Integer Linear Programming
May 22, 2002OSQ Retreat 1 CCured: Taming C Pointers George Necula Scott McPeak Wes Weimer
Symbolic Path Simulation in Path-Sensitive Dataflow Analysis Hari Hampapuram Jason Yue Yang Manuvir Das Center for Software Excellence (CSE) Microsoft.
Checking Memory Safety with BLAST Dirk Beyer, et al. FASE 2005 KAIST CS750b 2006 Fall Seonggun Kim.
Control hijacking attacks Attacker’s goal: – Take over target machine (e.g. web server) Execute arbitrary code on target by hijacking application control.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding ILPs with Branch & Bound ILP References: ‘Integer Programming’
©2005 GE Fanuc Automation, Inc. All Rights Reserved PACSystems Training Programmer’s Toolkit.
Thread-modular Abstraction Refinement Thomas A. Henzinger, et al. CAV 2003 Seonggun Kim KAIST CS750b.
CSC2108 Lazy Abstraction on Software Model Checking Wai Sum Mong.
Decision Procedures An Algorithmic Point of View
CREST Internal Yunho Kim Provable Software Laboratory CS Dept. KAIST.
1/20 Symbolic Execution and Program Testing Charngki PSWLAB Symbolic Execution and Program Testing James C.King IBM Thomas J.Watson Research Center.
GNU gcov (1/4) [from Wikipedia] gcov is a source code coverage analysis and statement- by-statement profiling tool. gcov generates exact counts of the.
Exploiting Buffer Overflows on AIX/PowerPC HP-UX/PA-RISC Solaris/SPARC.
Searching: Binary Trees and Hash Tables CHAPTER 12 6/4/15 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education,
Jose Sanchez 1 o Tielei Wang†, TaoWei†, Zhiqiang Lin‡, Wei Zou†. o Purdue University & Peking University o Proceedings of NDSS'09: Network and Distributed.
MILP algorithms: branch-and-bound and branch-and-cut
Pointers OVERVIEW.
Predicate Abstraction of ANSI-C Programs Using SAT By Edmund Clarke, Daniel Kroening, Natalia Sharygina, Karen Yorav Presented by Yunho Kim Provable Software.
Lazy Abstraction Jinseong Jeon ARCS, KAIST CS750b, KAIST2/26 References Lazy Abstraction –Thomas A. Henzinger et al., POPL ’02 Software verification.
Goal Seek and Solver. Goal seeking helps you n Find a specific value for a target cell by adjusting the value of one other cell whose value is allowed.
CSE 232: C++ debugging in Visual Studio and emacs C++ Debugging (in Visual Studio and emacs) We’ve looked at programs from a text-based mode –Shell commands.
Chapter 7 Pointers: Java does not have pointers. Used for dynamic memory allocation.
/21 Clang Tutorial CS453 Automated Software Testing.
1 4-Development Environment Development processor  The processor on which we write and debug our programs Usually a PC Target processor  The processor.
Software Verification Graph Model. 2 Graph Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases Specs Design Source.
A Tool for Pro-active Defense Against the Buffer Overrun Attack D. Bruschi, E. Rosti, R. Banfi Presented By: Warshavsky Alex.
Model Checking C Programs Zijiang (James) Yang Department of Computer Science Western Michigan University In collaboration with NEC Laboratories America.
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015Information Security, CS 5261.
Branch and Bound Algorithms Present by Tina Yang Qianmei Feng.
Model Checking C-Programs – An Example: Integer Square Root Wenhui Zhang
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
1 2 2 Call The Project Dynamic-Memory 4 4 # include "Utilities.hpp" int main(int argc, char * argv[]) { short int *PtrNo; (*PtrNo) = 5; printf ("(*PtrNo)
HW7: Due Dec 5th 23:59 1.Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
© 2006 Carnegie Mellon University Introduction to CBMC: Part 1 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Arie Gurfinkel,
Revisiting building. Preprocessing + Compiling 2 Creates an object file for each code file (.c ->.o) Each.o file contains code of the functions and structs.
Using System Calls (Unix) Have to tell compiler (if C/C++) where to find the headers, etc. – i.e., the “include” files May have to tell compiler where.
The software model checker BLAST Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala, Rupak Majumdar Presented by Yunho Kim TexPoint fonts used in EMF. Read.
Content Coverity Static Analysis Use cases of Coverity Examples
Integer Programming An integer linear program (ILP) is defined exactly as a linear program except that values of variables in a feasible solution have.
Protection of System Resources
Command-Line Arguments
High Coverage Detection of Input-Related Security Faults
Interprocess Communication (IPC)
Understanding Program Address Space
Introduction to Static Analyzer
Linear Programming Example: Maximize x + y x and y are called
Abstractions from Proofs
Predicate Abstraction
MOPS: an Infrastructure for Examining Security Properties of Software
We have the following incomplete B&B tree:
HW#7 Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw the complete execution.
Presentation transcript:

Generating Tests from Counterexamples Jinseong Jeon ARCS, KAIST

CS750b, KAIST 2/16 Actual Anxiety Counterexample! What makes him panic? What makes C.E. happen makes him panic!

CS750b, KAIST 3/16 Greater Goals Counterexample! How can it happen?  a test vector Any other cases?  a test suite

CS750b, KAIST 4/16 The Greatest Goal Automated Debugger! Program Target Pred. Test Driver Generator Test Suite Generator Test Driver Test Suite Testing

CS750b, KAIST 5/16 Contents Program Target Pred. Test Driver Generator Test Suite Generator Test Driver Test Suite Testing How to generate a test vector? How to generate a test suite? How to generate a test driver?

CS750b, KAIST 6/16 from Trace to Test (1/2) Example() { if (y == x) y++; if (z <= x) y++; a = y – z; if (a < x) LOC: } [ Program ] assume (y = x) y = y + 1 assume !(z <= x) a = y – z assume (a < x) [ Trace ] = = + 1 :  z,0> · = - [ Trace formula ] p, ( pc  LOC )

CS750b, KAIST 7/16 from Trace to Test (2/2) = = + 1 :  z,0> · = - [ Trace formula ]  0  y,1>  1  2  -1 [ Assignment ]  0  2 [ Test vector ] integer linear programming (ILP) solver

CS750b, KAIST 8/16 Linear Programming object function –maximize c 1 x 1 + c 2 x 2 problem constraints –a 11 x 1 + a 12 x 2 · b 1 –a 12 x 1 + a 22 x 2 · b 2 Algorithms –Simplex, Branch and Bound, etc. feasible region

CS750b, KAIST 9/16 An ILP Application Buffer Overrun Detection using Liner Programming and Static Analysis int main() { char header[2048], buf[1024], *cc1, *cc2, *ptr; int i; FILE *fp;... ptr = fgets(header, 2048, fp); cc1 = copy_buffer(header); for (i = 0; i < 10; i++) { ptr = fgets(buf, 1024, fp); cc2 = copy_buffer(buf); } header!alloc!max · 2048 header!alloc!min ¸ 0... header!used!max · 2048 header!used!min ¸ 1 cc1!used!max ¸ header!used!max cc1!used!min · header!used!min... i’!max ¸ i!max + 1 I’!min · i!min

CS750b, KAIST 10/16 Test Suite Gen. worklist à all locations in decreasing order of d.f.numbering Reach. Tree à a single node, the root test suite à ; while (worklist  ; ) { q à pop(worklist) p-trace à MC(Reach. Tree, p, q) if Reach. Tree is complete then worklist à ; else test suite à test suite [ { test_vector(p-trace) } } return test suite

CS750b, KAIST 11/16 Heuristics A test vector can cover several locations.  we can remove those locations from the worklist. MC’s unfolding (visiting) order  uncovered first, covered last Time-out option

CS750b, KAIST 12/16 Test Driver Gen. Original code Lib. call User input Test suite Test-feeding func. Test Driver

CS750b, KAIST 13/16 A Security Example (1/2) int saved_uid, saved_euid; work_and_drop_priv() { L5: FILE *fp = fopen(FILENAME,”w”); L6: if (!fp) { L7: return; } L8: // work L9: seteuid(saved_uid); } int get_root_privileges() { L1: if (saved_euid == 0) { L2: return -1; } L3: seteuid(0); L4: return 0; } int main(int argc, char *argv[]) { L10: saved_uid = getuid(); L11: saved_euid = geteuid(); L12: seteuid(saved_uid); L13: // work under normal mode L14: if (get_root_privileges() == 0 ) { L15: work_and_drop_priv(); } L16: execv(argv[1], argv+1); }

CS750b, KAIST 14/16 A Security Example (2/2) L10: saved_uid = getuid(); L11: saved_euid = geteuid(); L12: seteuid(saved_uid); L14: tmp = get_root_privileges(); L1: if (saved_euid != 0) /* fails */ L3: seteuid(saved_euid); L4: return 0; L14: if (tmp == 0) /* succeeds */ L15: work_and_drop_priv(); L5: fp = fopen(FILENAME, “w”); L6: if (!fp) /* succeeds */ L7: return; L16: /* uid = 0 */ [ A trace generated by BLAST ]

CS750b, KAIST 15/16 Experiments kbfiltr, floppy, cdaudio, parport, parclass  Microsoft Windows device drivers ping  an implementation of the ping utility ftpd  a Linux port of the ftp daemon

CS750b, KAIST 16/16 Conclusions pros –generate a test suite using model-checker –generate an automated debugger dead code detection, safety verification cons –only integer variables –what is really affected by BLAST?