Beyond Reachability: Shape Abstraction in the presence of Pointer Arithmetic Hongseok Yang (Queen Mary, University of London) (Joint work with Dino Distefano,

Slides:



Advertisements
Similar presentations
A Framework for describing recursive data structures Kenneth Roe Scott Smith.
Advertisements

Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Towards Shape Analysis for Device Drivers Hongseok Yang (Queen Mary, University of London) (Joint work with Josh Berdine, Cristiano Calcagno, Byron Cook,
TVLA for System Code Jörg KreikerHelmut SeidlVesal Vojdani TU Munich Dagstuhl, July 2009.
© 2009 Microsoft Corporation. All rights reserved. Automatic Verification of Heap Manipulation using Separation Logic Josh Berdine with thanks to Byron.
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A AAA A A A AA A Proving that non-blocking algorithms don't block.
PZ03D Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03D - Program verification Programming Language Design.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
HIP/SLEEK11 HIP/SLEEK :Automatic Verification and Specification Inference System Wei-Ngan Chin & Asankhaya Sharma Dept of Computer Science National University.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Chair of Software Engineering The alias calculus Bertrand Meyer ITMO Software Engineering Seminar June 2011.
Adjunct Elimination in Context Logic for Trees Cristiano Calcagno Thomas Dinsdale-Young Philippa Gardner Imperial College, London.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
ISBN Chapter 3 Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
Automated Soundness Proofs for Dataflow Analyses and Transformations via Local Rules Sorin Lerner* Todd Millstein** Erika Rice* Craig Chambers* * University.
Footprint Analysis: A Shape Analysis that Discovers Preconditions Hongseok Yang (Queen Mary, University of London) (Joint work with Cristiano Calcagno,
Discovering Affine Equalities Using Random Interpretation Sumit Gulwani George Necula EECS Department University of California, Berkeley.
Typed Assembly Languages COS 441, Fall 2004 Frances Spalding Based on slides from Dave Walker and Greg Morrisett.
A Combination Framework for Tracking Partition Sizes Sumit Gulwani, Microsoft Research Tal Lev-Ami, Tel-Aviv University Mooly Sagiv, Tel-Aviv University.
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.
From last time S1: l := new Cons p := l S2: t := new Cons *p := t p := t l p S1 l p tS2 l p S1 t S2 l t S1 p S2 l t S1 p S2 l t S1 p L2 l t S1 p S2 l t.
Overview of program analysis Mooly Sagiv html://
Describing Syntax and Semantics
Overview of program analysis Mooly Sagiv html://
1 Hardware synthesis 2.0 Byron Cook and Satnam Singh with Ashutosh Gupta, Stephen Magill, Andrey Rybalchenko, Jiri Simsa, and Viktor Vafeiadis TexPoint.
Instructor: Rajeev Alur
Reading and Writing Mathematical Proofs
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 2: Operational Semantics I Roman Manevich Ben-Gurion University.
Automatic Verification of Pointer Programs using Grammar-based Shape Analysis Hongseok Yang Seoul National University (Joint Work with Oukseh Lee and Kwangkeun.
Shape Analysis Overview presented by Greta Yorsh.
CS 363 Comparative Programming Languages Semantics.
© Andrew IrelandDependable Systems Group Cooperative Reasoning for Automatic Software Verification Andrew Ireland School of Mathematical & Computer Sciences.
A Certifying Compiler and Pointer Logic Zhaopeng Li Software Security Lab. Department of Computer Science and Technology, University of Science and Technology.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
Separation and Information Hiding Peter W. O’Hearn (Queen Mary, University of London) John C. Reynolds (Carnegie Mellon University) Hongseok Yang (Seoul.
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
Software Tamper Resistance: Obstructing Static Analysis of Programs Chenxi Wang, Jonathan Hill, John Knight, Jack Davidson at university of Virginia This.
Automated Verification with HIP and SLEEK Asankhaya Sharma.
1 MSR/Cambridge Formal Verification Overview Byron Cook Microsoft Research, Cambridge.
Proof by Contradiction CS 270 Math Foundations of CS Jeremy Johnson.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
This Week Lecture on relational semantics Exercises on logic and relations Labs on using Isabelle to do proofs.
Duminda WijesekeraSWSE 623: Introduction1 Introduction to Formal and Semi- formal Methods Based on A Specifier's Introduction to Formal Methods (J. Wing)
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Adaptive Shape Analysis Thomas Wies joint work with Josh Berdine Cristiano Calcagno TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Quantified Data Automata on Skinny Trees: an Abstract Domain for Lists Pranav Garg 1, P. Madhusudan 1 and Gennaro Parlato 2 1 University of Illinois at.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Abstract Interpretation and Future Program Analysis Problems Martin Rinard Alexandru Salcianu Laboratory for Computer Science Massachusetts Institute of.
Spring 2017 Program Analysis and Verification
Tutorial: Proving termination and liveness
Spring 2017 Program Analysis and Verification
Proof Carrying Code and Proof Preserving Program Transformations
Spring 2016 Program Analysis and Verification
Matching Logic An Alternative to Hoare/Floyd Logic
(One-Path) Reachability Logic
Formal Methods in Software Engineering 1
Ravi Mangal Mayur Naik Hongseok Yang
Spring 2017 Program Analysis and Verification Operational Semantics
Programming Languages and Compilers (CS 421)
Formal Methods in software development
Formal Methods in software development
Shape Analysis for Low-level Code
Spring 2016 Program Analysis and Verification Operational Semantics
Run-time environments
Presentation transcript:

Beyond Reachability: Shape Abstraction in the presence of Pointer Arithmetic Hongseok Yang (Queen Mary, University of London) (Joint work with Dino Distefano, Cristiano Calcagno and Peter O’Hearn)

Dream Automatically verify the memory safety of systems code, such as device derivers and memory managers. Challenges: 1. Pointer arithmetic. 2. Scalability. 3. Concurrency.

Our Analyzer Handles programs for dynamic memory management. Experimental results (Pentium 1.6GHz,512MB) Proved memory safety and even partial correctness. Found a hidden assumption of the K&R memory manager. These are “fixed” versions.

Hidden Assumption in K&R Malloc/Free Global VarsStack Heap

Hidden Assumption in K&R Malloc/Free Global VarsStack Heap

Hidden Assumption in K&R Malloc/Free Global VarsStack Heap

Hidden Assumption in K&R Malloc/Free Global VarsStack Heap

Hidden Assumption in K&R Malloc/Free Global VarsStack Heap

Sample Analysis Result Program: ans = malloc_bestfit_acyclic(n); Precondition: n ¸ 2 Æ mls(freep,0) Postcondition: (ans=0 Æ n ¸ 2 Æ mls(freep,0)) Ç (n ¸ 2 Æ nd(ans,q’,n) * mls(freep,0)) Ç (n ¸ 2 Æ nd(ans,q’,n) * mls(freep,q’) * mls(q’,0))

Rice Theorem Determining any nontrivial property of programs is not decidable.

Multiword Lists nil2 lp Link Field Size Field

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } p

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } 5 p

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } 5 p q

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } 5 p q

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } 5 p q

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } 5 p q

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } 5 p

Coalescing nil p = lp; while (p!=0) { local q = *p; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = q; } } 5 p=0 Nodeful High-level View Nodeless Low-level View Complex numerical relationships are used only for reconstructing a high-level view.

Separation Logic blk(p+2,p+5) nd(p,q,5) = def (p  q) * (p+1  5) * blk(p+2,p+5) mls(p,q) p+2p+5 5q p 34 2 q p

Program Analysis Collecting, approximate execution of programs that always terminates. while(x < y) { x = x+1; } x:1,y:2 x:2,y:2 x:2,y:4 x:4,y:4 x:+,y:+ x:+,y:+,x<y x:+,y:+ x:+,y:+,x>=y x:+,y:+

Our Analysis while(B) { C; } {T 1,T 2,…,T n } { T’ 1,T’ 2,…,T’ m } {Q 1, Q 2, …,Q n } Nodeful View: P(CanSymH) Nodeless View: P(SymH) {Q’ 1, Q’ 2, …,Q’ m } Rearrangement Abstraction Sym. Execution y=x+z Æ x  y*x+1  z*blk(x+2,0)*mls(y,0) nd(x,y,z) * mls(y,0)

Our Analysis while(B) { C; } {T 1,T 2,…,T n } { T’ 1,T’ 2,…,T’ m } {Q 1, Q 2, …,Q n } Nodeful View: P(CanSymH) Nodeless View: P(SymH) {Q’ 1, Q’ 2, …,Q’ m }

Abstraction Function Abs Abs : SymH ! CanSymH 1. Package all nodes. 2. Drop numerical relationships. 3. Combine two connected multiword lists. (5 · x+x Æ p+3=z’) Æ (p  q’ * p+1  3 * blk(p+2,z’) * mls(q’,0))

Abstraction Function Abs Abs : SymH ! CanSymH 1. Package all nodes. 2. Drop numerical relationships. 3. Combine two connected multiword lists. (5 · x+x Æ p+3=z’) Æ (nd(p,q’,3) * mls(q’,0))

Abstraction Function Abs Abs : SymH ! CanSymH 1. Package all nodes. 2. Drop numerical relationships. 3. Combine two connected multiword lists. (5 · x+x Æ p+3=z’) Æ (nd(p,q’,3) * mls(q’,0))

Abstraction Function Abs Abs : SymH ! CanSymH 1. Package all nodes. 2. Drop numerical relationships. 3. Combine two connected multiword lists. (nd(p,q’,3) * mls(q’,0))

Abstraction Function Abs Abs : SymH ! CanSymH 1. Package all nodes. 2. Drop numerical relationships. 3. Combine two connected multiword lists. (nd(p,q’,3) * mls(q’,0))

Abstraction Function Abs Abs : SymH ! CanSymH 1. Package all nodes. 2. Drop numerical relationships. 3. Combine two connected multiword lists. mls(p,0)

Coalescing while (p!=0){local q=p*; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = *p; } mls(lp,p) * mls(p,0) … p!=0 Æ mls(lp,p) * p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)* p  q,s’+t’ * blk(p+2,p+s’) *q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*q  r’,t’*blk(q+2,q+t’)*mls(r’,0)

Coalescing while (p!=0){local q=p*; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = *p; } mls(lp,p) * mls(p,0) … p!=0 Æ mls(lp,p) * p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)* p  q,s’+t’ * blk(p+2,p+s’) *q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q’ Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*q’  r’,t’*blk(q’+2,q’+t’)*mls(r’,0)

Coalescing while (p!=0){local q=p*; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = *p; } mls(lp,p) * mls(p,0) … p!=0 Æ mls(lp,p) * p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)* p  q,s’+t’ * blk(p+2,p+s’) *q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q’ Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*nd(q’,r’,t’) *mls(r’,0)

Coalescing while (p!=0){local q=p*; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = *p; } mls(lp,p) * mls(p,0) … p!=0 Æ mls(lp,p) * p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)* p  q,s’+t’ * blk(p+2,p+s’) *q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q’ Æ mls(lp,p)*nd(p,r’,s’+t’)* *mls(r’,0)

Coalescing while (p!=0){local q=p*; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = *p; } mls(lp,p) * mls(p,0) … p!=0 Æ mls(lp,p) * p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)* p  q,s’+t’ * blk(p+2,p+s’) *q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*q  r’,t’*blk(q+2,q+t’)*mls(r’,0) mls(lp,p)*nd(p,r’,s’+t’)* *mls(r’,0)

Coalescing while (p!=0){local q=p*; if (p + *(p+1) == q) { *(p+1) = *(p+1) + *(q+1); *p = *q; } else { p = *p; } mls(lp,p) * mls(p,0) … p!=0 Æ mls(lp,p) * p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  q,s’ * blk(p+2,p+s’) * mls(q,0) p!=0 Æ p+s’=q Æ mls(lp,p)* p  q,s’+t’ * blk(p+2,p+s’) *q  r’,t’*blk(q+2,q+t’)*mls(r’,0) p!=0 Æ p+s’=q Æ mls(lp,p)*p  r’,s’+t’*blk(p+2,p+s’)*q  r’,t’*blk(q+2,q+t’)*mls(r’,0) mls(lp,p)*mls(p,0)

Soundness Analysis results can be compiled into separation-logic proofs.

Conclusion: Analysis Design 1. Pick a class of target programs. 2. Observe properties of target programs. 3. Design a computable approximate semantics