stefan heule eric schkufza rahul sharma alex aiken
play

Stefan Heule, Eric Schkufza, Rahul Sharma, Alex Aiken PLDI, Santa - PowerPoint PPT Presentation

Stefan Heule, Eric Schkufza, Rahul Sharma, Alex Aiken PLDI, Santa Barbara, June 16, 2016 Symbolic Execution Automatically Program Reason about Verification Programs Program Equivalence 2 Automatically reasoning about


  1. Stefan Heule, Eric Schkufza, Rahul Sharma, Alex Aiken PLDI, Santa Barbara, June 16, 2016

  2. Symbolic Execution Automatically Program 𝜚 ≑ Reason about Verification Programs Program ≑ Equivalence … 2

  3. Automatically reasoning about programs requires 3

  4. testq %rdi , %rdi je .L1 xorq %rax , %rax .L0: movq %rdi , %rdx andq $0x1, %rdx addq %rdx , %rax shrq $0x1, %rdi jne .L0 cltq retq .L1: xorq %rax , %rax retq 4

  5. 64-bit bit-vector addition rax ← rax + 64 1 64 addq $0x1, %rax 64-bit constant previous value of rax 5

  6. rax ← rax + 64 1 64 addq $0x1, %rax al ← al + 8 1 8 addb $0x1, %al 6

  7. rax ← rax + 64 1 64 addq $0x1, %rax al ← al + 8 1 8 addb $0x1, %al rax 64 bits eax 32 bits ax 16 bits ah al 8 bits 8 bits 7

  8. rax ← rax + 64 1 64 addq $0x1, %rax al ← al + 8 1 8 addb $0x1, %al rax ← rax 63: 8 ∘ rax 7: 0 + 8 1 8 rax 64 bits eax 32 bits ax 16 bits ah al 8 bits 8 bits 8

  9. rax ← rax + 64 1 64 addq $0x1, %rax rax ← rax 63: 8 ∘ rax 7: 0 + 8 1 8 addb $0x1, %al rax ← rax 63: 16 ∘ rax 15: 0 + 16 1 16 addw $0x1, %ax rax ← rax[63: 32] ∘ (rax[31: 0] + 32 1 32 ) addl $0x1, %eax 9

  10. rax ← rax + 64 1 64 addq $0x1, %rax rax ← rax 63: 8 ∘ rax 7: 0 + 8 1 8 addb $0x1, %al rax ← rax 63: 16 ∘ rax 15: 0 + 16 1 16 addw $0x1, %ax rax ← 0 32 ∘ (rax[31: 0] + 32 1 32 ) addl $0x1, %eax 10

  11. rax ← rax + 64 1 64 addq $0x1, %rax rax ← rax 63: 8 ∘ rax 7: 0 + 8 1 8 addb $0x1, %al rax ← rax 63: 16 ∘ rax 15: 0 + 16 1 16 addw $0x1, %ax rax ← 0 32 ∘ (rax[31: 0] + 32 1 32 ) addl $0x1, %eax zf ← 0 32 = (eax + 32 1 32 ) cf ← 0 1 ∘ eax + 33 1 33 [32,32] sf ← eax + 32 1 32 [31,31] of ← Β¬eax 31,31 ∧ (eax + 32 1 32 )[31,31] pf ← (eax + 32 1 32 )[0,0] βŠ• (eax + 32 1 32 )[1,1] βŠ• (eax + 32 1 32 )[2,2] βŠ• (eax + 32 1 32 )[3,3] βŠ• (eax + 32 1 32 )[4,4] βŠ• (eax + 32 1 32 )[5,5] βŠ• (eax + 32 1 32 )[6,6] βŠ• (eax + 32 1 32 )[7,7] 11

  12. β€’ Manual partial specifications – CompCert [CACM’09] , BAP [CAV’11] , BitBlaze [ICISS’08] , Codesurfer/x86 [ETAPS’05] , McVeto [CAV’10] , STOKE [ASPLOS’13] , Jakstab [CAV’08] , many others β€’ Taly/Godefroid [PLDI’12] – Automatically synthesize specification from templates – Only 534 instructions 13

  13. Bit-vector formulas of input-output behavior 14

  14. All instructions Remaining Instructions Base set Learn specification automatically Specify manually 15

  15. combine base Program π‘ž Instruction 𝑗 formulas synthesize Formula 𝜚 How do we Formal synthesize guarantee? 𝑗 ≑ 𝜚 programs? 16

  16. combine base Program π‘ž Instruction 𝑗 formulas synthesize Formula 𝜚 Randomized search How do we Guided by cost function synthesize Based on test-cases programs? Using STOKE [ASPLOS’13] 17

  17. combine base Program π‘ž Instruction 𝑗 formulas synthesize Formula 𝜚 Formal π‘ž ≑ 𝜚 guarantee? 𝑗 ≑ 𝜚 18

  18. combine base Program π‘ž Instruction 𝑗 formulas synthesize Formula 𝜚 Formal 𝑗 ≑ π‘ž ≑ 𝜚 guarantee? 𝑗 ≑ 𝜚 19

  19. combine base Program π‘ž Instruction 𝑗 formulas synthesize Candidate formula 𝜚 Formal 𝑗 ≑ π‘ž ≑ 𝜚 guarantee? 𝑗 ≑ 𝜚 20

  20. combine base Program π‘ž Instruction 𝑗 formulas synthesize Candidate formula 𝜚 Candidate Program π‘žβ€² formula πœšβ€² Candidate … formula πœšβ€²β€² yes βœ” increase confidence ? πœšβ€² 𝜚 ֞ Add counter example, remove wrong program(s) no 21

  21. Increase confidence Remove incorrect program(s) ? πœšβ€² 𝜚 ֞ No information about equivalence 22

  22. Increase confidence Remove incorrect program(s) ? πœšβ€² 𝜚 ֞ No information about equivalence 23

  23. Increase confidence Remove incorrect program(s) ? πœšβ€² 𝜚 ֞ No information about equivalence Equivalence class 1 Equivalence class 2 24

  24. Equivalence class 1 Equivalence class 2 Equivalence class 3 β€’ Prefer programs whose formulas are – Precise (fewest uninterpreted functions) – Fast (fewest non-linear arithmetic operations) – Simple (fewest nodes) 25

  25. Equivalence class 1 Equivalence class 2 Equivalence class 3 β€’ Prefer programs whose formulas are – Precise (fewest uninterpreted functions) – Fast (fewest non-linear arithmetic operations) – Simple (fewest nodes) 26

  26. synthesize 27

  27. 28

  28. Learn dx ← dx + 16 ax addw %ax , %dx Rename addw %cx , %bx bx ← bx + 16 cx βœ” dx ← dx + 16 M rsp βœ” addw ( %rsp ), %dx dx ← dx + 16 5 16 addw $0x5, %dx βœ” 29

  29. 1. Learn formula for register-only instructions 2. Generalize formulas ‐ To other types of operands 3. Check on test inputs 30

  30. shufps $0xb3, %xmm0 , %xmm1 Problem: No corresponding register-only variant Solution: Brute force a formula for every constant 31

  31. β€’ Base set (51 instructions) – Integer, bitwise and float operations – Data movement (including conditional move) – Conversion operations β€’ Pseudo instructions (11 templates) – Split and combine registers – Changing status flags 32

  32. β€’ Total instructions 3,684 β€’ Out-of-scope – System instructions invpcid, jle 302 – Crypto instructions aeskeygenassist 35 – Deprecated instructions fadd 332 – String instructions scasq 97 β€’ Goal instructions 2,918 33

  33. β€’ Base set 51 β€’ Pseudo instructions 11 β€’ Register-only instructions learned 692 β€’ Generalized 984 β€’ 8-bit constant instructions learned 119.42 β€’ Total formulas learned 1,795.42 34

  34. Compare with handwritten formulas (from STOKE) Available for comparison 1,431.91 Automatically proven equivalent 1,377.91 4 Equivalent with additional lemma 35

  35. Compare with handwritten formulas (from STOKE) Available for comparison 1,431.91 fadd 𝑏, 𝑐 = fadd 𝑐, 𝑏 Automatically proven equivalent 1,377.91 4 Equivalent with additional lemma 36

  36. Compare with handwritten formulas (from STOKE) Available for comparison 1,431.91 Automatically proven equivalent 1,377.91 4 Equivalent with additional lemma Semantically different 50 Handwritten formula correct 0 Learned formula correct 50 37

  37. Stratum 1 Stratum 3 Stratum 0 Stratum 2 base set 0 if 𝑗 ∈ baseset stratum 𝑗 = ࡝ 𝑗 β€² βˆˆπ‘(𝑗) stratum i β€² 1 + max otherwise 38

  38. 0 if 𝑗 ∈ baseset stratum 𝑗 = ࡝ 𝑗 β€² βˆˆπ‘(𝑗) stratum i β€² 1 + max otherwise 39

  39. 800 Number of formulas learned 700 600 500 400 300 200 100 0 0 50 100 150 200 250 Wall-clock time elapsed [hours] Stratification Without stratification 40

  40. Fully inlined: 3526 instructions number of nodes in learned formula number of nodes in handwritten formula 41

  41. 1. Automatically learned 1,795 formulas 2. Stratification key to scale program synthesis 3. Compare to hand-written specification ‐ More correct, equally precise, same size Source code, formulas, experimental results https://github.com/StanfordPL/strata/ 42

  42. 43

  43. 1. Missing base instructions Some integer and floating point operations are missing 2. Program synthesis limits Shortest known program is long and outside of reach e.g., byte-vectorized operation 3. Cost function limitation For one bit of output, the cost function does not give enough signal 4. Crazy instructions 44

  44. β€’ Total decisions 7,075 β€’ Equivalent 6,669 (94.26%) β€’ New equivalence class 356 (5.03%) β€’ Counter-examples 50 (0.71%) β€’ β€’ Timeouts (45 seconds): 3 45

  45. β€’ Intel Xeon E5-2697 (28 cores) at 2.6 GHz – 268.86 hours (register-only) – 159.12 hours (8-bit constants) β€’ Total of 11,983.37 core hours 46

  46. β€’ Random inputs (random machine state) β€’ β€œInteresting” bit -patterns 0 , 1 , βˆ’1 , 2 π‘œ , NaN , Infinity β€’ Test cases learned from counter-examples 47

  47. β€’ Formulas are simplified – Constant propagation ≑ 8 64 2 64 βˆ— 64 4 64 – Move bit-selection over concatenation 0 64 ∘ rax 63,0 ≑ rax 48

  48. β€’ Formula precision (number of uninterpreted functions) – Learned formulas equally precise in all but 4 cases β€’ Formula quality (number of non-linear operations) – Learned formulas contain same number of non- linear operations, except for 11 cases 49

Recommend


More recommend