pointer manipulating programs
play

pointer-manipulating programs Nadia Polikarpova joint work with - PowerPoint PPT Presentation

SuSLik: synthesis of safe pointer-manipulating programs Nadia Polikarpova joint work with Ilya Sergey (Yale-NUS) follow along https://github.com/TyGuS/suslik-tutorial 2 pointer-manipulating programs network / security operating systems


  1. { y ↦ b1 } { y ↦ a1 } | ⇝ ?? (Frame) { x ↦ b1 ∗ y ↦ a1 } | { x ↦ b1 ∗ y ↦ b1 } ⇝ ?? (Write) { x ↦ b1 ∗ y ↦ a1 } | { x ↦ a1 ∗ y ↦ b1 } ⇝ *x = b1; ?? (Read) { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 } | ⇝ let b1 = *y; ?? (Read) { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } | ⇝ let a1 = *x; ??

  2. { y ↦ a1 } { y ↦ a1 } | ?? ⇝ (Write) { y ↦ b1 } { y ↦ a1 } | ⇝ *y = a1; ?? (Frame) { x ↦ b1 ∗ y ↦ a1 } | { x ↦ b1 ∗ y ↦ b1 } ⇝ ?? (Write) { x ↦ b1 ∗ y ↦ a1 } { x ↦ a1 ∗ y ↦ b1 } | ⇝ *x = b1; ?? (Read) { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 } | ⇝ let b1 = *y; ?? (Read) { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } | ⇝ let a1 = *x; ??

  3. { emp } { emp } | ?? ⇝ (Frame) { y ↦ a1 } { y ↦ a1 } | ?? ⇝ (Write) { y ↦ b1 } { y ↦ a1 } | ⇝ *y = a1; ?? (Frame) { x ↦ b1 ∗ y ↦ a1 } | { x ↦ b1 ∗ y ↦ b1 } ⇝ ?? (Write) { x ↦ b1 ∗ y ↦ a1 } | { x ↦ a1 ∗ y ↦ b1 } ⇝ *x = b1; ?? (Read) { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 } | ⇝ let b1 = *y; ?? (Read) { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } | ⇝ let a1 = *x; ??

  4. (Emp) { emp } { emp } | ⇝ skip (Frame) { y ↦ a1 } { y ↦ a1 } | ?? ⇝ (Write) { y ↦ b1 } { y ↦ a1 } | ⇝ *y = a1; ?? (Frame) { x ↦ b1 ∗ y ↦ a1 } | { x ↦ b1 ∗ y ↦ b1 } ⇝ ?? (Write) { x ↦ b1 ∗ y ↦ a1 } | { x ↦ a1 ∗ y ↦ b1 } ⇝ *x = b1; ?? (Read) { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 } | ⇝ let b1 = *y; ?? (Read) { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } | ⇝ let a1 = *x; ??

  5. { x ↦ A * y ↦ B } let a1 = *x; let b1 = *y; *x = b1; *y = a1; skip { x ↦ B * y ↦ A }

  6. demo 4: tracing swap 76

  7. synthetic separation logic (SSL) • basic rules (Emp), (Read), (Write), (Frame) (Alloc), (Free) • pure reasoning and unification • inductive predicates and recursion 77

  8. synthetic separation logic (SSL) • basic rules (Emp), (Read), (Write), (Frame) (Alloc), (Free) • pure reasoning and unification • inductive predicates and recursion 78

  9. example: dispose a list void dispose( loc x) { list(x) } { emp } 79

  10. { list 1 (x) } void dispose( loc x) { emp } { list 0 (x) } (Induction) ?? { emp }

  11. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list 0 (x) } (Open) ?? { emp }

  12. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { { x = 0 ; emp } ?? { emp } } else { { x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list 1 (Y) } ?? { emp } }

  13. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { { x = 0 ; emp } (Emp) ?? { emp } } else { { x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list 1 (Y) } ?? { emp } }

  14. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { { x = 0 ; emp } skip { emp } } else { { x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list 1 (Y) } ?? { emp } }

  15. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { { x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list 1 (Y) } ?? { emp } }

  16. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { { x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list 1 (Y) } (Read) ?? { emp } }

  17. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { let y1 = *(x + 1); { x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ y1 ∗ list 1 (y1) } ?? { emp } }

  18. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { let y1 = *(x + 1); { x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ y1 ∗ list 1 (y1) } (Free) ?? { emp } }

  19. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { let y1 = *(x + 1); free x; { x ≠ 0 ; list 1 (y1) } ?? { emp } }

  20. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { let y1 = *(x + 1); free x; { x ≠ 0 ; list 1 (y1) } (Call) ?? { emp } }

  21. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { let y1 = *(x + 1); free x; dispose(y1); { x ≠ 0 ; emp } ?? { emp } }

  22. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { let y1 = *(x + 1); free x; dispose(y1); { x ≠ 0 ; emp } (Emp) ?? { emp } }

  23. predicate list (loc x) { { list 1 (x) } void dispose( loc x) { emp } | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } if (x == 0) { skip } else { let y1 = *(x + 1); free x; dispose(y1); skip }

  24. void dispose( loc x) { if (x == 0) { } else { let y1 = *(x + 1); free x; dispose(y1) } 94

  25. synthetic separation logic (SSL) • basic rules (Emp), (Read), (Write), (Frame), (Alloc), (Free) • pure reasoning and unification • inductive predicates and recursion (Open), (Close), (Induction), (Call) 95

  26. this tutorial 1. example: swap 2. intro to separation logic 3.deductive synthesis 3.1. proof system 3.2. proof search 96

  27. SuSLik backtracking search in SSL + optimizations

  28. demo 5: backtracking 98

  29. optimizations • invertible rules • early failure • multi-phase search • symmetry reduction 99

  30. optimization: invertible rules • invertible rules do not restrict the set of derivable programs • idea: invertible rules need not be backtracked (Read) [y/A]{ x ↦ A ∗ P } ⇝ [y/A]{ Q } | c { x ↦ A ∗ P } ⇝ { Q } | let y = *x; c 100

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend