Separation and Information Hiding Peter W. O’Hearn (Queen Mary, University of London) John C. Reynolds (Carnegie Mellon University) Hongseok Yang (Seoul.

Slides:



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

Soundness of Higher-order Frame Rules (How did category theory help me?) Hongseok Yang Seoul National University Joint work with Lars Birkedal and Noah.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 12.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Techniques for proving programs with pointers A. Tikhomirov.
Chapter 6 Data Types
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Prof. Necula CS 164 Lecture 141 Run-time Environments Lecture 8.
Adjunct Elimination in Context Logic for Trees Cristiano Calcagno Thomas Dinsdale-Young Philippa Gardner Imperial College, London.
Memory Management Design & Implementation Segmentation Chapter 4.
Certifying Low-Level Programs with Hardware Interrupts and Preemptive Threads Xinyu Feng Toyota Technological Institute at Chicago Joint work with Zhong.
CS 536 Spring Run-time organization Lecture 19.
3/17/2008Prof. Hilfinger CS 164 Lecture 231 Run-time organization Lecture 23.
On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and.
Local Reasoning Peter O’Hearn John Reynolds Hongseok Yang.
Separation Logic A Logic of Shared Mutable Data Structures John Reynolds CMU Extended subset Mooly Sagiv.
Run time vs. Compile time
1 Islands : Aliasing Protection In Object-Oriented Languages By : John Hogg OOPSLA 91 Aharon Abadi.
Run-time Environment and Program Organization
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Programming Language Semantics Axiomatic Semantics of Parallel Programs.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Verifying a Wait Free Register Algorithm Using Assertional Reasoning Xu Qiwen Faculty of Science and Technology University of Macau.
Crowfoot: a verifier for higher order store programs Billiejoe (Nathaniel) Charlton Ben Horsfall Bernhard Reus University of Sussex VMCAI 2012.
Chapter 7: Runtime Environment –Run time memory organization. We need to use memory to store: –code –static data (global variables) –dynamic data objects.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
Automatic Verification of Pointer Programs using Grammar-based Shape Analysis Hongseok Yang Seoul National University (Joint Work with Oukseh Lee and Kwangkeun.
Aquinas Hobor and Cristian Gherghina (National University of Singapore) TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Axiomatic Methods for Software Verification Hongseok Yang.
Storage Management. The stack and the heap Dynamic storage allocation refers to allocating space for variables at run time Most modern languages support.
Concurrency Verification. Why concurrency verification Concurrent programs show in many systems –Multi-task support in OS kernels –Handling interrupts.
© Andrew IrelandDependable Systems Group Cooperative Reasoning for Automatic Software Verification Andrew Ireland School of Mathematical & Computer Sciences.
VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages.
Chapter 9 Pointers and Dynamic Arrays (9.1). Pointers A variables which holds the memory address for a variable of a specific type. Call-by-Reference.
A Certifying Compiler and Pointer Logic Zhaopeng Li Software Security Lab. Department of Computer Science and Technology, University of Science and Technology.
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
Towards a General Theory of Local Actions Hongseok Yang Seoul National University Peter O’Hearn Queen Mary, University of London.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
CIS 720 Correctness of Concurrent Programs. i := 1 max := A[1] do i < n  i = i + 1 if (max < A[i]) max = A[i] od.
Beyond Reachability: Shape Abstraction in the presence of Pointer Arithmetic Hongseok Yang (Queen Mary, University of London) (Joint work with Dino Distefano,
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
1 Verification of object-oriented programs with invariants Mike Barnett, Robert DeLine, Manuel Fahndrich, K. Rustan M. Leino, Wolfram Schulte ECOOP 2003.
Extension of Separation Logic for Stack Reasoning Jiang Xinyu.
Separation Logic (II) Acknowledgment: slides taken from Reynolds’ mini-course CS 818A3.
Data Types In Text: Chapter 6.
Formal Modeling Concepts
Storage Management.
Records Design Issues: 1. What is the form of references?
11.1 The Concept of Abstraction
This pointer, Dynamic memory allocation, Constructors and Destructor
Concurrent Separation Logic
Lecture 5 Floyd-Hoare Style Verification
Cooperative Reasoning for Automatic Software Verification
Separation Logic and Concurrency Verification
Concurrent Separation Logic
Concurrent Separation Logic
Shape Analysis for Low-level Code
Separation Logic Acknowledgment: slides taken from Reynolds’ mini-course CS 818A3.
Program correctness Axiomatic semantics
RUN-TIME STORAGE Chuen-Liang Chen Department of Computer Science
More C++ Classes Systems Programming.
Run-time environments
11.1 The Concept of Abstraction
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

Separation and Information Hiding Peter W. O’Hearn (Queen Mary, University of London) John C. Reynolds (Carnegie Mellon University) Hongseok Yang (Seoul National University)

Modularity Without modularity, formal reasoning is doomed. Pointers can breach module boundaries. Rule out naughty pointers? Too debilitating. Separation logic: flexible protection of module internals. Module procedure 1 procedure n …. x

Proper Proof Rule for a Module Hoare (72) gave a proof rule for a module. The internal state is hidden from a client. Scoping restrictions protect internal resource from outside interference. But, with pointers, this proof rule is not sound. Our goal is to find a proof rule for a module such that 1. it works even with pointers, and 2. it hides the internals from a client.

Separation Logic by Examples Atomic assertions: emp, (1  0), (1  -) Separating conjunction p*q : (x  -)*(y  -) Tight interpretation of Hoare triples: {emp}[x]:=0{true} --- Invalid {x  -}[x]:=0{true} --- Valid

Toy Memory Manager alloc x free x Memory_Manager f nil global variable x

Toy Memory Manager alloc x free x Memory_Manager f nil global variable x

Implementations alloc x free x Memory_Manager f nil Implementations: alloc x = if (f=nil) then x:=new() else x:=f; f:=[f] free x = [x]:=f; f:=x Specifications: {emp*list(f)} alloc x {(x  -)*list(f)} {(x  -)*list(f)} free x {emp*list(f)}

Implementations alloc x free x Memory_Manager f nil Implementations: alloc x = if (f=nil) then x:=new() else x:=f; f:=[f] free x = [x]:=f; f:=x Specifications: {emp*list(f)} alloc x {(x  -)*list(f)} {(x  -)*list(f)} free x {emp*list(f)} Resource Invariant: list(f)

Client-side Reasoning alloc x free x Memory_Manager f alloc x ; [x] := y; free x ; nil

Client-side Reasoning alloc x free x Memory_Manager f {emp * list(f)} alloc x ; {(x  -) * list(f)} [x] := y; {(x  y) * list(f)} free x ; {emp * list(f)} nil

Client-side Reasoning alloc x free x Memory_Manager f {emp} alloc x ; {(x  -)} [x] := y; {(x  y)} free x ; {emp} nil

Client-side Reasoning alloc x free x Memory_Manager f {emp} alloc x ; {(x  -)} [x] := y; {(x  y)} free x ; {emp} [x] := x list(f) is not preserved. nil x

Towards Good Client-side Reasoning Confinement: Prevents a client from pointing to the internals of a module. Doesn’t work for the memory manager. Our approach: Well-specified programs mind their own business. Consequently, they don’t interfere with the module internals. Much more general.

Our Solution Modular Procedure Call ` {emp * list(f)} C 1 {(x  -) * list(f)} ` {(x  -) * list(f)} C 2 {emp * list(f)} {emp}alloc x {x  -},{x  -}free x {emp} ` {p} C {q} ` {p*list(f)}let alloc x =C 1, free x =C 2 in C{q*list(f)}

Our Solution Modular Procedure Call ` {emp * list(f)} C 1 {(x  -) * list(f)} ` {(x  -) * list(f)} C 2 {emp * list(f)} {emp}alloc x {x  -},{x  -}free x {emp} ` {p} C {q} ` {p*list(f)}let alloc x =C 1, free x =C 2 in C{q*list(f)} ` {emp * list(f)} C 1 {(x  -) * list(f)} ` {(x  -) * list(f)} C 2 {emp * list(f)}

Our Solution Modular Procedure Call ` {emp * list(f)} C 1 {(x  -) * list(f)} ` {(x  -) * list(f)} C 2 {emp * list(f)} {emp}alloc x {x  -},{x  -}free x {emp} ` {p} C {q} ` {p*list(f)}let alloc x =C 1, free x =C 2 in C{q*list(f)} The internal list is absent in client-side reasoning. {emp}alloc x {x  -},{x  -}free x {emp} ` {p} C {q}

Our Solution Modular Procedure Call ` {emp * slist(f)} C 1 {(x  -) * slist(f)} ` {(x  -) * slist(f)} C 2 {emp * slist(f)} {emp}alloc x {x  -},{x  -}free x {emp} ` {p} C {q} ` {p*slist(f)}let alloc x =C 1, free x =C 2 in C{q*slist(f)} The internal list is absent in client-side reasoning. So, the same proof for the client works for different implementations. {emp}alloc x {x  -},{x  -}free x {emp} ` {p} C {q}

Protection from Outside Interference Tie a cycle in the free list. alloc x ; free x ; [x] := x Failed proof attempt: {emp} alloc x ; {x  -} free x ; {emp} [x] := x {???} emp does not ensure that the heap cell x exists. Thus, ??? cannot be filled in.

Ownership Reading of a Triple In client-side reasoning, we use {x  -}free x {emp}. How can emp hold when the cell x still exists? Assertions describe owned local storage, not global storage. f x Cells owned by the client Cells owned by the module nil Heap Storage

Ownership Reading of a Triple In client-side reasoning, we use {x  -}free x {emp}. How can emp hold when the cell x still exists? Assertions describe owned local storage, not global storage. f x Cells owned by the client Cells owned by the module nil Heap Storage

Main Results Modular Procedure Rule  ` {p 1 *r}C 1 {q 1 *r} ……  ` {p n *r}C n {q n *r} , {p i }k i {q i } (i · n) ` {p}C{q}  ` {p*r}let k 1 =C 1,…,k n =C n in C{q*r} The modular procedure rule is sound for a fixed r iff r is precise. The modular procedure rule is sound for fixed p 1,…,p n iff all of p 1,…,p n are precise.

Conclusion Separation enables modularity and information hiding even with pointers. No special restrictions needed. Dangling pointers and address arithemetic all OK. Ownership transfer: sharp end of pointers.