Formal Verification – Robust and Efficient Code 1 iCSC2016, Kim Albertsson, LTU Formal Verification – Robust and Efficient Code Lecture 2 Why FV? Kim Albertsson.

Slides:



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

Masahiro Fujita Yoshihisa Kojima University of Tokyo May 2, 2008
A System to Generate Test Data and Symbolically Execute Programs Lori A. Clarke September 1976.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
LIFE CYCLE MODELS FORMAL TRANSFORMATION
Ashish Kundu CS590F Purdue 02/12/07 Language-Based Information Flow Security Andrei Sabelfield, Andrew C. Myers Presentation: Ashish Kundu
The Design and Implementation of a Certifying Compiler [Necula, Lee] A Certifying Compiler for Java [Necula, Lee et al] David W. Hill CSCI
An Integration of Program Analysis and Automated Theorem Proving Bill J. Ellis & Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt.
SD3049 Formal Methods Module Leader Dr Aaron Kans Module website
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
ECE Synthesis & Verification1 ECE 667 Spring 2011 Synthesis and Verification of Digital Systems Verification Introduction.
Programmability with Proof-Carrying Code George C. Necula University of California Berkeley Peter Lee Carnegie Mellon University.
Invariant Based Programming, March 20101/ Teaching the construction of correct programs using invariant based programming Ralph-Johan Back Johannes Eriksson.
Validating High-Level Synthesis Sudipta Kundu, Sorin Lerner, Rajesh Gupta Department of Computer Science and Engineering, University of California, San.
OOP #10: Correctness Fritz Henglein. Wrap-up: Types A type is a collection of objects with common behavior (operations and properties). (Abstract) types.
A Type System for Expressive Security Policies David Walker Cornell University.
Describing Syntax and Semantics
School of Computer ScienceG53FSP Formal Specification1 Dr. Rong Qu Introduction to Formal Specification
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Extensible Untrusted Code Verification Robert Schneck with George Necula and Bor-Yuh Evan Chang May 14, 2003 OSQ Retreat.
Formal Techniques for Verification Using SystemC By Nasir Mahmood.
Formal Methods 1. Software Engineering and Formal Methods  Every software engineering methodology is based on a recommended development process  proceeding.
CS527: (Advanced) Topics in Software Engineering Overview of Software Quality Assurance Tao Xie ©D. Marinov, T. Xie.
System/Software Testing
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
CUTE: A Concolic Unit Testing Engine for C Technical Report Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
© Andrew IrelandDependable Systems Group Proof Automation for the SPARK Approach to High Integrity Ada Andrew Ireland Computing & Electrical Engineering.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
1 New Development Techniques: New Challenges for Verification and Validation Mats Heimdahl Critical Systems Research Group Department of Computer Science.
Framework for the Development and Testing of Dependable and Safety-Critical Systems IKTA 065/ Supported by the Information and Communication.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
BE-SECBS FISA 2003 November 13th 2003 page 1 DSR/SAMS/BASP IRSN BE SECBS – IRSN assessment Context application of IRSN methodology to the reference case.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Page 1 Advanced Technology Center HCSS 03 – April 2003 vFaat: von Neumann Formal Analysis and Annotation Tool David Greve Dr. Matthew Wilding Rockwell.
© Andrew IrelandDependable Systems Group Static Analysis and Program Proof Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University.
Reasoning about programs March CSE 403, Winter 2011, Brun.
© Andrew IrelandDependable Systems Group Proof Automation for the SPARK Approach to High Integrity Ada Andrew Ireland Computing & Electrical Engineering.
Formal Methods.
1 Model Checking of Robotic Control Systems Presenting: Sebastian Scherer Authors: Sebastian Scherer, Flavio Lerda, and Edmund M. Clarke.
Verification & Validation By: Amir Masoud Gharehbaghi
Using Symbolic PathFinder at NASA Corina Pãsãreanu Carnegie Mellon/NASA Ames.
Version 02U-1 Computer Security: Art and Science1 Correctness by Construction: Developing a Commercial Secure System by Anthony Hall Roderick Chapman.
(1) Introduction to Continuous Integration Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of.
SAFE KERNEL EXTENSIONS WITHOUT RUN-TIME CHECKING George C. Necula Peter Lee Carnegie Mellon U.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Week 6 MondayTuesdayWednesdayThursdayFriday Testing III Reading due Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Formal Verification – Robust and Efficient Code Lecture 1
Cs498dm Software Testing Darko Marinov January 24, 2012.
The PLA Model: On the Combination of Product-Line Analyses 강태준.
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Types for Programs and Proofs
John Backes, Rockwell Collins Dan DaCosta, Rockwell Collins
Program Verification Using
UNIT-4 BLACKBOX AND WHITEBOX TESTING
A Trusted Safety Verifier for Process Controller Code
Department of Computer Science Abdul Wali Khan University Mardan
CUTE: A Concolic Unit Testing Engine for C
John Backes, Rockwell Collins Dan DaCosta, Rockwell Collins
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

Formal Verification – Robust and Efficient Code 1 iCSC2016, Kim Albertsson, LTU Formal Verification – Robust and Efficient Code Lecture 2 Why FV? Kim Albertsson Luleå University of Technology Inverted CERN School of Computing, 29 February – 2 March 2016

Formal Verification – Robust and Efficient Code 2 iCSC2016, Kim Albertsson, LTU Introduction  Kim Albertsson  M.Sc. Engineering Physics and Electrical Engineering  Currently studying for M.Sc. Computer Science  Research interests  Automation  Machine learning  Formal methods  Great way to automate tedious tasks Luleå You are here Image from Wikimedia Commons, the free media repository

Formal Verification – Robust and Efficient Code 3 iCSC2016, Kim Albertsson, LTU Formal Methods  Managing complexity  “…mathematically based languages, techniques, and tools for specifying and verifying … systems.” Edmund M. Clarke et al.  Reveals inconsistencies and ambiguities

Formal Verification – Robust and Efficient Code 4 iCSC2016, Kim Albertsson, LTU Formal Methods  Specification + Model + Implementation enables verification  Proving properties for a system  Will my algorithm sort the input?  Will my soda pop be delivered in time?  Can the LHC interlock system end up in an inconsistent state?

Formal Verification – Robust and Efficient Code 5 iCSC2016, Kim Albertsson, LTU Overview Series  Approaches  Model Checking and Theorem Proving  Logic and automation  How to build an ecosystem  Application  Robust code  Robust and Efficient code

Formal Verification – Robust and Efficient Code 6 iCSC2016, Kim Albertsson, LTU Recap of Lecture 1  FV manages complexity  Finds errors early  Save money, time and possibly life  Proof is a demonstration  Consistency of specification and implementation Image from Wikimedia Commons, the free media repository

Formal Verification – Robust and Efficient Code 7 iCSC2016, Kim Albertsson, LTU Recap of Lecture 1  Proving properties about your system  Model Checking  Exhaustive search of state space  Theorem Proving  Deductive approach

Formal Verification – Robust and Efficient Code 8 iCSC2016, Kim Albertsson, LTU Recap of Lecture 1  Theorem Proving  Based on First Order Logic  Satisfiability Modulo Theories (SMT) solvers to find application of rules  IVT platforms front-end with many SMT backends

Formal Verification – Robust and Efficient Code 9 iCSC2016, Kim Albertsson, LTU Introduction Lecture 2  Robust Code verification Code synthesis  Robust and Efficient Verified tool-chain Proof carrying code  Bonus! Concolic Testing

Formal Verification – Robust and Efficient Code 10 iCSC2016, Kim Albertsson, LTU Introduction Lecture 2  Errors discovered late  Expensive  FV requires  More effort for specification  FV gives  Feedback on inconsistencies  Reduces late errors  Reduces total time

Formal Verification – Robust and Efficient Code 11 iCSC2016, Kim Albertsson, LTU Introduction Lecture 2  FV and static analysis related  Discovering bugs at compile-time rather than run-time  Mainstream tools slowly developing  Free candy!  Can we do better while minimising effort? Image from Wikimedia Commons, the free media repository

Formal Verification – Robust and Efficient Code 12 iCSC2016, Kim Albertsson, LTU Introduction Lecture 2  Trust, correctness and code  First order logic and SMT solvers  Tedious to use for non- trivial problems  What tools are available today?

Formal Verification – Robust and Efficient Code 13 iCSC2016, Kim Albertsson, LTU Overview  Robust Code verification Code synthesis  Robust and Efficient Verified tool-chain Proof carrying code  Bonus! Concolic Testing

Formal Verification – Robust and Efficient Code 14 iCSC2016, Kim Albertsson, LTU Robust  High-level verifiers  VCC, Frama-C, … many more  Code compilation is separate  Integrate with IVT Platforms  Uses specialised solvers  Annotations directly in code

Formal Verification – Robust and Efficient Code 15 iCSC2016, Kim Albertsson, LTU Code Verification  VCC, Verifier for Concurrent C us/projects/vcc/  Verification of Microsoft Hyper-V  As of 2009 partially complete  Moderately large ~100 kloc  Must guarantee no leakage between host and guest

Formal Verification – Robust and Efficient Code 16 iCSC2016, Kim Albertsson, LTU Code Verification #include "vcc.h" int max(int a, int b) _(ensures \result == (a > b ? a : b)) { if (a > b) return a; return b; }

Formal Verification – Robust and Efficient Code 17 iCSC2016, Kim Albertsson, LTU Code Verification  Frama-C  Framework for Modular Analysis of C programs  Modular framework for static analysis  Focus on correctness  Provides verification of C programs  Through the Jessie plug-in  Uses specification to analyze code  More than just verification  e.g. value analysis, impact analysis.

Formal Verification – Robust and Efficient Code 18 iCSC2016, Kim Albertsson, LTU Code requires a < 100 && b < ensures \result >= a && \result >= ensures \result == a || \result == b; */ int max (int a, int b) { if (a > b) return a; return b; }

Formal Verification – Robust and Efficient Code 19 iCSC2016, Kim Albertsson, LTU

Formal Verification – Robust and Efficient Code 20 iCSC2016, Kim Albertsson, LTU Code Synthesis  Is code redundant?  Synthesise implementation from specification  Requires completeness  Implementation is constructive proof  Security focus  Requires more power than first order logic

Formal Verification – Robust and Efficient Code 21 iCSC2016, Kim Albertsson, LTU Code Synthesis  Coq, the proof assistant  From french word for rooster  Successor to Calculus of Constructions (CoC)  Proof management system  Based on higher order logic  Functional programming language  with sophisticated type system

Formal Verification – Robust and Efficient Code 22 iCSC2016, Kim Albertsson, LTU Overview  Robust Code verification Code synthesis  Robust and Efficient Verified tool-chain Proof carrying code  Bonus! Concolic Testing

Formal Verification – Robust and Efficient Code 23 iCSC2016, Kim Albertsson, LTU Robust and Efficient  Efficient code is always desirable  Specification allows specific optimisations But the bigger issue is, your tool-chain has bugs Even if you trust your source code, you can’t trust the byte code Verify the tool-chain!

Formal Verification – Robust and Efficient Code 24 iCSC2016, Kim Albertsson, LTU Robust and Efficient  Explicit assumptions leveraged for better byte- code  Array out-of-bounds checks unnecessary  Automatic parallelisation of loops  Dereferencing null-pointers is ok!  Similar to whole module optimisations but locally!

Formal Verification – Robust and Efficient Code 25 iCSC2016, Kim Albertsson, LTU Robust and Efficient  Efficient code is always desirable  Specification allows specific optimisations  Another issue; Your tool- chain has bugs  Even if you trust your source code, you can’t trust the byte code  Verify the tool-chain!

Formal Verification – Robust and Efficient Code 26 iCSC2016, Kim Albertsson, LTU Verified tool-chain  Tool-chain of today  No absolute guarantee of correctness  Trust each tool in tool chain (verified with testing)  Each tool by different programmers  Each tool must be trusted!

Formal Verification – Robust and Efficient Code 27 iCSC2016, Kim Albertsson, LTU Verified tool-chain  A verified tool chain  Still requires trust  Reduces number of places where you have to put it  Provides consistency guarantees

Formal Verification – Robust and Efficient Code 28 iCSC2016, Kim Albertsson, LTU Verified tool-chain  CompCert, a verified C Compiler  Guarantees optimised AST retains equivalent semantics  Can be extended to provide byte code guarantees  Requires a model of memory management (language semantics)

Formal Verification – Robust and Efficient Code 29 iCSC2016, Kim Albertsson, LTU Verified tool-chain  Covers a language very close to C called CLight  Does not support variable length arrays, unstructured switch-statements and longjmp/setjmp  No immediate plans for c++  Verified by automatic + interactive methods + Correct-by- construction  Performs consistently worse than gcc -O1, but surprisingly close to  10% worse than -O1, 15% worse than -O2, 20% worse than -O3  Cannot handle matrix multiplications very well as of

Formal Verification – Robust and Efficient Code 30 iCSC2016, Kim Albertsson, LTU Verified tool-chain  No example, it works as-is on your code!

Formal Verification – Robust and Efficient Code 31 iCSC2016, Kim Albertsson, LTU Proof Carrying Code  Extends verification  Cover external code  Proof delivered alongside code  Secure and performant  Tampering leads to invalidated proofs

Formal Verification – Robust and Efficient Code 32 iCSC2016, Kim Albertsson, LTU Proof Carrying Code  Verification before execution  Clear safety policy  Model of language semantics  Language models are collaborative effort  Proof language  First order logic  Higher order logic

Formal Verification – Robust and Efficient Code 33 iCSC2016, Kim Albertsson, LTU Proof Carrying Code  G. Necula and P. Lee 1996  Safe packet filters  Time critical application  High security  Customisability  User-space code run in kernel space

Formal Verification – Robust and Efficient Code 34 iCSC2016, Kim Albertsson, LTU Proof Carrying Code  Safe sharing of code without encryption  OS kernel  Across the Internet  XSS, grid-like applications  Minimal to no performance hit

Formal Verification – Robust and Efficient Code 35 iCSC2016, Kim Albertsson, LTU Overview  Robust Code verification Code synthesis  Robust and Efficient Verified tool-chain Proof carrying code  Bonus! Concolic Testing

Formal Verification – Robust and Efficient Code 36 iCSC2016, Kim Albertsson, LTU Concolic Testing  Concolic, concrete + symbolic  Proofs reason about area, tests about points  Specification used for white-box testing  i.e. generating test cases  Not perfect, but efficient  Achieves high code coverage quickly

Formal Verification – Robust and Efficient Code 37 iCSC2016, Kim Albertsson, LTU Concolic Testing  Execution splits at branches  Constraints updated for new paths  Symbolical path is resolved  When “exception” happens  Yields concrete example  To figure out concrete path  Use constraint solver (SMT)

Formal Verification – Robust and Efficient Code 38 iCSC2016, Kim Albertsson, LTU Concolic Testing int get_sign(int x) { if (x == 0) return 0; if (x <= 0) return -1; else return 1; }

Formal Verification – Robust and Efficient Code 39 iCSC2016, Kim Albertsson, LTU Concolic Testing  KLEE, from the painter Paul Klee  Applied to unix’ coreutils in 2008  Found several serious bugs  Coreutils is thoroughly tested through exposure  Successfully handled programs of up to 10 kloc in ~1h per program  Beat hand constructed test-suites built over 15 years  Integrates well with standard tools (llvm)

Formal Verification – Robust and Efficient Code 40 iCSC2016, Kim Albertsson, LTU Concolic Testing $ llvm-gcc --emit-llvm -c -g get_sign.c $ klee get_sign.o int get_sign(int x) { if (x == 0) return 0; if (x < 0) return -1; else return 1; } int main() { int a; klee_make_symbolic(&a, sizeof(a), "a"); return get_sign(a); }

Formal Verification – Robust and Efficient Code 41 iCSC2016, Kim Albertsson, LTU Concolic Testing $ ktest-tool --write-ints klee-last/test ktest ktest file : 'klee-last/test ktest' args : ['get_sign.o'] num objects: 1 object 0: name: 'a' object 0: size: 4 object 0: data: 1 $ ktest-tool --write-ints klee-last/test ktest... object 0: data: -2 $ ktest-tool --write-ints klee-last/test ktest... object 0: data: 0

Formal Verification – Robust and Efficient Code 42 iCSC2016, Kim Albertsson, LTU Recap Lecture 2  Robust Code verification Code synthesis  Robust and Efficient Verified tool-chain Proof carrying code  Bonus! Concolic Testing

Formal Verification – Robust and Efficient Code 43 iCSC2016, Kim Albertsson, LTU Recap Lecture 2  Robust Code verification Code synthesis  Robust and Efficient Verified tool-chain Proof carrying code  Bonus! Concolic Testing

Formal Verification – Robust and Efficient Code 44 iCSC2016, Kim Albertsson, LTU Recap Lecture 2  Robust Code verification Code synthesis  Robust and Efficient Verified tool-chain Proof carrying code  Bonus! Concolic Testing

Formal Verification – Robust and Efficient Code 45 iCSC2016, Kim Albertsson, LTU Recap Lecture 2  Formal methods, applied where correctness is important  Large collaborative projects  Verified tool-chains  …  Benefits for all  Robustness and quality  Taught in school?

Formal Verification – Robust and Efficient Code 46 iCSC2016, Kim Albertsson, LTU Thank you