Differential Assertion Checking and Relative Correctness in Software Verification

Slide Note
Embed
Share

Differential assertion checking compares two similar programs to identify errors, while relative correctness ensures all assertions pass, highlighting failed assertions. The content discusses the challenges and benefits of these techniques in software verification, with examples of correct and buggy implementations of the strcopy function.


Uploaded on Sep 24, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Differential Assertion Checking Shuvendu Lahiri Kenneth McMillan Rahul Sharma Chris Hawblitzel

  2. Assertion Checking void strcopy (char* dst, char*src, int size) { int i=0; for(;i<size-1 && *src; i++) *dst++ = *src++; *dst = 0; } assert(Valid(x)) before every *x Given a program ? With a spec to verify Assertions E.g., memory safety Find executions that violate the specification Make some assertion fail

  3. Assertion Checking is Hard void strcopy (char* dst, char*src, int size) { int i=0; for(;i<size-1 && *src; i++) *dst++ = *src++; *dst = 0; } Every pointer dereference is flagged as a warning What is valid memory? ?1= [src, src+size 1], Loop invariants? ??? ?1, Ensure tractability Weaker guarantees E.g., testing, BMC,

  4. Correctness -> Relative Correctness Given two similar programs ?? and ?? A one to one map between procedures and variables Find an input All assertions in ?? pass Some assertion in ?? fails Practical and useful Equivalence checking not applicable More tractable than traditional assertion checking A mechanism to find regressions

  5. Relative Correctnesss (Bug) void strcopy_correct (char* dst, char*src, int size) { int i = 0; for(;i<size-1 && *src; i++) *dst++ = *src++; *dst = 0; } void strcopy_buggy (char* dst, char*src, int size) { int i = 0; for(;*src && i<size-1; i++) *dst++ = *src++; *dst = 0; } CEX: size=0, src =0, dst= some valid location

  6. Relative Correctness (Proof) void strcopy_buggy (char* dst, char*src, int size) { int i=0; for(;*src && i<size-1; i++) *dst++ = *src++; *dst = 0; } void strcopy_correct (char* dst, char*src, int size) { int i=0; for(;i<size-1 && *src; i++) *dst++ = *src++; *dtmp = 0; } No need to constrain the inputs Invariants: src.1=src.2, dst.1=dst.2, size.1=size.2, i.1=i.2

  7. Differential Assertion Checking Given two programs ?1 and ?2, ?2 has a differential error w.r.t. ?1 if there is an input state ? s.t. there exists a non-failing execution P1? and a failing execution of P2? 1. 2.

  8. DAC(?2,?1) to Assertion Checking ?1?2 ?2 ?1 bool ok1; bool ok2; ok1:=ok2:=true; main1 main2 main1main2 assert ok1=>ok2 n1 n2 n1n2 assert b assert b ok1:=ok1 && b ok2:=ok2 && b

  9. Composed Program proc f1(x1): r1 modifies g1 { s1; L1: w1 := call h1(e1); t1 } proc f2(x2): r2 modifies g2 { s2; L2: w2 := call h2(e2); t2 }

  10. Main Result For two procedures ?1 and ?2, ?1?1 = ?1 iff ?1?2?1 ?2 = ?1 and ?2?2 = ?2 ?2 The joint procedure ?1?2 precisely captures ?1 and ?2 Holds even in the presence of loops and recursion

  11. Implementation Workflow Invariant templates Booleans: ?1 ?2,?2 ?1 Integers: ?1 ?2,?2 ?1 Otherwise: ?1= ?2 Houdini P1.bpl SymDiff annotated P1P2.bpl P1P2.bpl P2.bpl Boogie SMT Verifying bug fixes Filtering alarms Z3

  12. Verifying Bug Fixes Did a fix inadvertently introduce new bugs Verisec suite: snippets of open source programs which contain buffer overflow vulnerabilities, as well as corresponding patched versions. Relative buffer overflow checking Examples include apache, madwifi, sendmail,

  13. Example int main_buggy() { fb := 0; while(c1=read()!=EOF) { fbuf[fb] = c1; fb++; } } int main_patched() { fb := 0; while(c1=read()!=EOF) { fbuf[fb] = c1; fb++; if(fb >= MAX) fb = 0; } } Invariant:fb.2<=fb.1 Buffer Overflow

  14. Filtering Warnings DAC removes warnings from ?2 that are present in ?1 Modular analyses analyze procedures in isolation Typically results in a large number of warnings Two case studies: Software artifacts infrastructure repository (in paper) Windows Vista vs Windows 7 device drivers Relative null pointer dereference

  15. WDK results

  16. Related Work Joshi et al. 12: Differential errors for bounded programs Relative properties of approx. program transformations (Carbin et al. 12, 13) No automatic tool for checking these Equivalence checking: Translation validation, validating program refactorings Product programs (Barthe et al. 11, Pnueli et al. 08)

  17. Conclusion A new form of relative correctness, from assertions Complementary to equivalence and refinement A modular composition procedure Enables decomposition of the proof Use off-the-shelf verifiers for differential checking Implementation inside SymDiff for automated proofs Future work: inference techniques, further evaluation

Related


More Related Content