State your reasons or how to keep proofs while optimizing code

Slides:



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

New Security Issues Raised by Open Cards Pierre GirardJean-Louis Lanet GERMPLUS R&D.
Mobile Code Security Yurii Kuzmin. What is Mobile Code? Term used to describe general-purpose executables that run in remote locations. Web browsers come.
1 Regression-Verification Benny Godlin Ofer Strichman Technion.
Mobile Code Security Aviel D. Rubin, Daniel E. Geer, Jr. MOBILE CODE SECURITY, IEEE Internet Computing, 1998 Minkyu Lee
Ashish Kundu CS590F Purdue 02/12/07 Language-Based Information Flow Security Andrei Sabelfield, Andrew C. Myers Presentation: Ashish Kundu
CS 355 – Programming Languages
An Introduction to Proof-Carrying Code David Walker Princeton University (slides kindly donated by George Necula; modified by David Walker)
The Design and Implementation of a Certifying Compiler [Necula, Lee] A Certifying Compiler for Java [Necula, Lee et al] David W. Hill CSCI
Code-Carrying Proofs Aytekin Vargun Rensselaer Polytechnic Institute.
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
Proof-system search ( ` ) Interpretation search ( ² ) Main search strategy DPLL Backtracking Incremental SAT Natural deduction Sequents Resolution Main.
Programmability with Proof-Carrying Code George C. Necula University of California Berkeley Peter Lee Carnegie Mellon University.
Program analysis Mooly Sagiv html://
OOP #10: Correctness Fritz Henglein. Wrap-up: Types A type is a collection of objects with common behavior (operations and properties). (Abstract) types.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
A Type System for Expressive Security Policies David Walker Cornell University.
Overview of program analysis Mooly Sagiv html://
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Introduction to Optimization Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Describing Syntax and Semantics
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.
Secure Virtual Architecture John Criswell, Arushi Aggarwal, Andrew Lenharth, Dinakar Dhurjati, and Vikram Adve University of Illinois at Urbana-Champaign.
X-Road – Estonian Interoperability Platform
Chapter 1 Introduction. Goal to learn about computers and programming to compile and run your first Java program to recognize compile-time and run-time.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
Proof-Carrying Code & Proof-Carrying Authentication Stuart Pickard CSCI 297 June 2, 2005.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
© Andrew IrelandDependable Systems Group Static Analysis and Program Proof Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Semantics In Text: Chapter 3.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
A Flexible Access Control Service for Java Mobile Code HPCC lab 문 정 아.
Software Quality Assurance and Testing Fazal Rehman Shamil.
Understand Windows Services Software Development Fundamentals LESSON 5.3.
SAFE KERNEL EXTENSIONS WITHOUT RUN-TIME CHECKING George C. Necula Peter Lee Carnegie Mellon U.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
CSE 60641: Operating Systems George C. Necula and Peter Lee, Safe Kernel Extensions Without Run-Time Checking, OSDI ‘96 –SIGOPS Hall of fame citation:
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Enabling Control over Adaptive Program Transformation for Dynamically Evolving Mobile Software Validation Mike Jochen, Anteneh Anteneh, Lori Pollock University.
Credible Compilation With Pointers Martin Rinard and Darko Marinov Laboratory for Computer Science Massachusetts Institute of Technology.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Principles of Programming & Software Engineering
A Review of Software Testing - P. David Coward
Introduction to Optimization
Types for Programs and Proofs
Textbook: Principles of Program Analysis
Proof Carrying Code and Proof Preserving Program Transformations
Introduction
Introduction Enosis Learning.
Introduction CSE 1310 – Introduction to Computers and Programming
Introduction Enosis Learning.
Introduction to Optimization
Logical architecture refinement
Lecture 5 Floyd-Hoare Style Verification
Objective of This Course
Programming Languages 2nd edition Tucker and Noonan
Generating Optimal Linear Temporal Logic Monitors by Coinduction
Semantics In Text: Chapter 3.
Information Security CS 526
Introduction to Optimization
Lecture 06:Software Maintenance
Java History, Editions, Version Features
Lecture 19: Proof-Carrying Code Background just got here last week
String Analysis for JavaScript Programs Using JSAI
Programming Languages 2nd edition Tucker and Noonan
COP4020 Programming Languages
Presentation transcript:

State your reasons or how to keep proofs while optimizing code Ando Saabas, Institute of Cybernetics EXCS kick-off meeting, 18. September 2008

Outline Background – extensible systems Proof carrying code – general overview Proof compilation

Background Mobile code and extensible systems popular (and increasingly more so) Code Host Device driver Applet Loaded procedures Operating system Web browser Database server

What should the extensions guarantee? Security is a concern Safety properties: Accesses only its own memory Doesn’t leak sensitive data Uses resources properly Doesn’t eat up all the memory Holds a limited number of locks Functional properties Provides the functionality it promises

Runtime monitoring Monitor A monitor detects attempts to violate the safety policy and stops the execution Relatively simple; effective for many properties Inflexible (no guarantees on functional properties) Computationally expensive

Digital signatures “Company X produced this software” PKI “Company X produced this software” Simple, well established techniques No direct connection with program semantics

Proof Carrying Code Proof-Carrying Code is based on the idea that the code producer should provide some evidence that the program she distributes is safe and/or functionally correct. The program is shipped with a certificate that attests that it has the desired properties. Before running a program, the code user checks this certificate and only runs the code if it is safe

Proof carrying code Proof Proof Checker

PCC: An analogy The user doesn’t try to solve a problem, only check a solution

PCC vs Digital Signatures A digital signature identifies the origin of the program A PCC certificate identifies the meaning of the program A digital signature is a syntactic checksum A PCC certificate is a semantic checksum

Where would proofs come from? For basic safety properties, they can be inferred automatically For more complex safety and/or functional correctness properties, the code producer would use some verification environment to prove the source program correct But programs are distributed in compiled form

PCC framework ? Code producer Code user Binary Proof Proof Checker Specification Source program Program verification environment Binary Compiler + Proof compiler ? Proof Proof Checker Program proof

Proof compilation For non-optimizing compilers it is easy: proof compilation is (almost) identity Not so if optimizations take place

Dead code elimination f 9 p : s = c ¤ n ^ g f s = c ¤ n ^ p g f 9 p : Precondition f 9 p : s = ^ 1 i g f s = ^ p 1 i g while i < n s = s + c; skip; i++; while i < n s = s + c; p = p * c; i++; Invariant f 9 p : s = c ¤ i ^ · n g f s = c ¤ i ^ p · n g Postcondition f 9 p : s = c ¤ n ^ g f s = c ¤ n ^ p g

Constant propagation f s = c ¤ n ^ p g f s = ^ p 1 i g f s = 5 ¤ i ^ p Precondition f s = ^ p 1 i g c = 5; while i < n s = s + c; p = p * c; i++; c = 5; while i < n s = s + 5; p = p * 5; i++; Invariant f s = 5 ¤ i ^ p · n g f s = c ¤ i ^ p · n 5 g f s = c ¤ i ^ p < n g Postcondition f s = c ¤ n ^ p g

Proof compilation For non-optimizing compilers it is easy: proof compilation is (almost) identity Not so if optimizations take place Many different optimizations, each have their own particular effect on the proof Need a systematic approach for dealing with this

State your reasons There is always a reason why certain parts of code can be modified during optimization These reasons should be stated – recorded – in the assertions. But how do we know exactly where and what is to be recorded? c = 5; while i < n s = s + 5; p = p * 5; i++; c = 5; while i < n s = s + c; p = p * c; i++; We know c is always 5 in the loop Invariant f s = c ¤ i ^ p · n g f s = c ¤ i ^ p · n 5 g

Enter type systems Optimizations are mostly based on dataflow analyses Dataflow analyses can be described as type systems Type systems can have an optimization component Type annotations can show us what needs to be stated where when transforming proofs

PCC framework ? Code producer Code user Proof Proof Checker Source Specification Source program Program verification environment Compiler + Proof compiler ? Proof Proof Checker Program proof

PCC framework Proof Source program Program optimizer Type Analyzer derivation Program optimizer Proof optimizer Proof Program proof

Type system for dead code elimination

How applicable is the approach? The approach works on all classical program optimizations Scales to complicated, code structure changing optimizations such as partial redundancy elimination Can be used for optimization which require bidirectional analyses – many non-trivial bytecode transformations Can be applied to both high level and CFG based program and analysis descriptions Implementation for Java bytecode analyses: dead store elimination load pop pair elimination store load pair elimination etc

Conclusions It is important to get the basic notions and tools right – type systems are exactly the right tool when trying to describe what optimizations are doing They lend their hand for formal reasoning about optimizations – proving soundess, certain optimality results etc Soundness of the optimization makes it possible to transform a program’s proof along the program guided by its analysis type derivation – record and exploit what you know, and it will come out right

Acknowledgements I would like to thank Estonian Doctoral School in ICT, EITSA Tiger University Plus programme and the Estonian Association of Information Technology and Telecommunications (ITL) for their financial support.