Cross-Architecture Li/er Synthesis Rijnard van Tonder and - - PowerPoint PPT Presentation

cross architecture li er synthesis
SMART_READER_LITE
LIVE PREVIEW

Cross-Architecture Li/er Synthesis Rijnard van Tonder and - - PowerPoint PPT Presentation

Cross-Architecture Li/er Synthesis Rijnard van Tonder and Claire Le Goues Cross-Architecture Li/er Synthesis Rijnard van Tonder and Claire Le Goues


slide-1
SLIDE 1

Cross-­‑Architecture ¡Li/er ¡Synthesis ¡

Rijnard ¡van ¡Tonder ¡and ¡Claire ¡Le ¡Goues ¡ ¡ ¡

slide-2
SLIDE 2

Cross-­‑Architecture ¡Li/er ¡Synthesis ¡

Rijnard ¡van ¡Tonder ¡and ¡Claire ¡Le ¡Goues ¡ ¡ ¡

slide-3
SLIDE 3

3 ¡

What ¡is ¡a ¡Li/er? ¡

slide-4
SLIDE 4

4 ¡

What ¡is ¡a ¡Li/er? ¡

x86 ¡ ARM ¡ … ¡

Lower ¡level ¡code ¡

slide-5
SLIDE 5

5 ¡

What ¡is ¡a ¡Li/er? ¡

x86 ¡ ARM ¡ … ¡

Lower ¡level ¡code ¡ Architecture-­‑speci3ic ¡

slide-6
SLIDE 6

6 ¡

What ¡is ¡a ¡Li/er? ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

slide-7
SLIDE 7

7 ¡

What ¡is ¡a ¡Li/er? ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

Higher ¡level ¡code ¡

slide-8
SLIDE 8

8 ¡

What ¡is ¡a ¡Li/er? ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

Higher ¡level ¡code ¡ Architecture-­‑agnostic ¡

slide-9
SLIDE 9

9 ¡

Why ¡Li/ers? ¡

slide-10
SLIDE 10

10 ¡

Why ¡Li/ers? ¡

  • Binary ¡analysis ¡
slide-11
SLIDE 11

11 ¡

Why ¡Li/ers? ¡

  • Binary ¡analysis ¡
  • Simpler ¡semantic ¡abstraction ¡

– E.g., ¡symbolic ¡execution ¡

slide-12
SLIDE 12

12 ¡

Why ¡Li/ers? ¡

  • Binary ¡analysis ¡
  • Simpler ¡semantic ¡abstraction ¡

– E.g., ¡symbolic ¡execution ¡

  • Reuse ¡analysis ¡components ¡

– Control ¡3low ¡graph ¡construction ¡ – Single ¡Static ¡Assignment ¡(SSA) ¡conversion ¡

slide-13
SLIDE 13

13 ¡

Compilers ¡and ¡Decompilers ¡

  • Compilers ¡lose ¡information ¡

– Translation ¡is ¡not ¡a ¡bijection ¡ ¡

slide-14
SLIDE 14

14 ¡

Compilers ¡and ¡Decompilers ¡

  • Compilers ¡lose ¡information ¡

– Translation ¡is ¡not ¡a ¡bijection ¡

  • Decompilers ¡recover ¡more ¡features ¡

– Often ¡architecture-­‑speci3ic ¡(e.g., ¡ABI) ¡

slide-15
SLIDE 15

15 ¡

The ¡Problem: ¡ Transla?ng ¡Mul?ple ¡Architectures ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

Manual ¡

slide-16
SLIDE 16

16 ¡

The ¡Problem: ¡ Transla?ng ¡Mul?ple ¡Architectures ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

Manual ¡ 1000s ¡of ¡manual ¡pages ¡

slide-17
SLIDE 17

17 ¡

Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

slide-18
SLIDE 18

18 ¡

Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

[1] ¡Stra@fied ¡synthesis: ¡automa@cally ¡learning ¡the ¡x86-­‑64 ¡instruc@on ¡set. ¡Heule ¡et ¡al. ¡

[1] ¡

slide-19
SLIDE 19

19 ¡

Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

Cross-­‑Architecture ¡reuse ¡

slide-20
SLIDE 20

20 ¡

Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

Bug-­‑3inding ¡Analyses ¡“for ¡free” ¡

slide-21
SLIDE 21

21 ¡

Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡

x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡

Bug-­‑3inding ¡Analyses ¡“for ¡free” ¡ Data3low ¡framework ¡ VC ¡Generation ¡ Taint ¡analysis ¡

slide-22
SLIDE 22

22 ¡

What ¡We ¡Do ¡

slide-23
SLIDE 23

23 ¡

What ¡We ¡Do ¡

  • IR ¡translation ¡as ¡a ¡Syntax-­‑Guided ¡Synthesis ¡

problem ¡

slide-24
SLIDE 24

24 ¡

What ¡We ¡Do ¡

  • IR ¡translation ¡as ¡a ¡Syntax-­‑Guided ¡Synthesis ¡

problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡

slide-25
SLIDE 25

25 ¡

What ¡We ¡Do ¡

  • IR ¡translation ¡as ¡a ¡Syntax-­‑Guided ¡Synthesis ¡

problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡ ≡ ¡∀x ¡. ¡oracle(x) ¡= ¡P(x) ¡

slide-26
SLIDE 26

26 ¡

What ¡We ¡Do ¡

  • IR ¡translation ¡as ¡a ¡Syntax-­‑Guided ¡Synthesis ¡

problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡ ≡ ¡∀x ¡. ¡oracle(x) ¡= ¡P(x) ¡

Correctness ¡speci3ication ¡

slide-27
SLIDE 27

27 ¡

What ¡We ¡Do ¡

  • IR ¡translation ¡as ¡a ¡Syntax-­‑Guided ¡Synthesis ¡

problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡ ≡ ¡∀x ¡. ¡oracle(x) ¡= ¡P(x) ¡

Dynamic ¡Input/Output ¡Pairs ¡

slide-28
SLIDE 28

28 ¡

What ¡We ¡Do ¡

  • IR ¡translation ¡as ¡a ¡Syntax-­‑Guided ¡Synthesis ¡

problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡ ≡ ¡∀x ¡. ¡oracle(x) ¡= ¡P(x) ¡

Dynamic ¡Input/Output ¡Pairs ¡ IR ¡Sketches ¡

slide-29
SLIDE 29

29 ¡

What ¡We ¡Do ¡

  • IR ¡translation ¡as ¡a ¡Syntax-­‑Guided ¡Synthesis ¡

problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡ ≡ ¡∀x ¡. ¡oracle(x) ¡= ¡P(x) ¡

IR ¡Sketches ¡

Key ¡Insight: ¡ Learn ¡IR ¡Sketches ¡from ¡ existing ¡Lifter ¡Productions ¡

slide-30
SLIDE 30

30 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

slide-31
SLIDE 31

31 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

add ¡R3, ¡R0 ¡ ARM ¡

slide-32
SLIDE 32

32 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡

slide-33
SLIDE 33

33 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡ Op ¡codes ¡and ¡register ¡names ¡

slide-34
SLIDE 34

34 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

LIFT ¡ add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡ Manual ¡translation ¡rules ¡

slide-35
SLIDE 35

35 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

LIFT ¡ add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡ Manual ¡translation ¡rules ¡ Intel ¡x86: ¡1500-­‑page ¡manual ¡ ARM: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡1000-­‑page ¡manual ¡

slide-36
SLIDE 36

36 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ IR ¡Instruc?on ¡ SOURCE ¡ TARGET ¡

slide-37
SLIDE 37

37 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ IR ¡Instruc?on ¡ SOURCE ¡ TARGET ¡ IR ¡with ¡operational ¡semantics ¡

slide-38
SLIDE 38

38 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ IR ¡SKETCH ¡

slide-39
SLIDE 39

39 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ Create ¡sketches ¡from ¡concrete ¡expressions ¡ IR ¡SKETCH ¡

slide-40
SLIDE 40

40 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

  • Learn ¡templates ¡from ¡lifter ¡output ¡for ¡a ¡

supported ¡architecture ¡to ¡synthesize ¡one ¡ for ¡an ¡unsupported ¡architecture ¡

slide-41
SLIDE 41

41 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ Create ¡sketches ¡from ¡concrete ¡expressions ¡ IR ¡ IR ¡SKETCH ¡

slide-42
SLIDE 42

42 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ add ¡$1, ¡$2 ¡ MIPS ¡ IR ¡ IR ¡SKETCH ¡

slide-43
SLIDE 43

43 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ IR ¡ IR ¡SKETCH ¡

slide-44
SLIDE 44

44 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ IR ¡ IR ¡SKETCH ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡

slide-45
SLIDE 45

45 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

_ ¡:= ¡_ ¡+ ¡_ ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ IR ¡SKETCH ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡

slide-46
SLIDE 46

46 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

_ ¡:= ¡_ ¡+ ¡_ ¡ IR ¡SKETCH ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ SYNTHESIS ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡

slide-47
SLIDE 47

47 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

_ ¡:= ¡_ ¡+ ¡_ ¡ IR ¡SKETCH ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ SYNTHESIS ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡

I/O ¡from ¡execu@ng ¡add ¡$1, ¡$2 ¡

slide-48
SLIDE 48

48 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

_ ¡:= ¡_ ¡+ ¡_ ¡ IR ¡SKETCH ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ SYNTHESIS ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡

I/O ¡from ¡execu@ng ¡add ¡$1, ¡$2 ¡

slide-49
SLIDE 49

49 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ IR ¡SKETCH ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ SYNTHESIS ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡ IR ¡

I/O ¡from ¡execu@ng ¡add ¡$1, ¡$2 ¡

slide-50
SLIDE 50

50 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

  • Learn ¡templates ¡from ¡lifter ¡output ¡for ¡a ¡

supported ¡architecture ¡to ¡synthesize ¡one ¡ for ¡an ¡unsupported ¡architecture ¡

slide-51
SLIDE 51

51 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

  • Learn ¡templates ¡from ¡lifter ¡output ¡for ¡a ¡

supported ¡architecture ¡to ¡synthesize ¡one ¡ for ¡an ¡unsupported ¡architecture ¡

  • Code ¡is ¡“natural” ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡shared ¡semantic ¡

properties ¡

slide-52
SLIDE 52

52 ¡

Learning ¡Sketch ¡Templates: ¡Example ¡

  • Learn ¡templates ¡from ¡lifter ¡output ¡for ¡a ¡

supported ¡architecture ¡to ¡synthesize ¡one ¡ for ¡an ¡unsupported ¡architecture ¡

  • Code ¡is ¡“natural” ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡shared ¡semantic ¡

properties ¡

  • Sketch ¡templates ¡exploit ¡structural ¡qualities ¡

to ¡guide ¡synthesis ¡

slide-53
SLIDE 53

53 ¡

Synthesis ¡Approach ¡

slide-54
SLIDE 54

54 ¡

Na?ve ¡Behavior ¡

  • I/O ¡pairs ¡from ¡

native ¡execution ¡ ¡

Synthesis ¡Approach ¡

slide-55
SLIDE 55

55 ¡

Na?ve ¡Behavior ¡

  • I/O ¡pairs ¡from ¡

native ¡execution ¡

  • QEMU ¡and ¡PIN ¡

traces ¡ ¡ ¡

Synthesis ¡Approach ¡

slide-56
SLIDE 56

56 ¡

Na?ve ¡Behavior ¡

  • I/O ¡pairs ¡from ¡

native ¡execution ¡

  • QEMU ¡and ¡PIN ¡

traces ¡ ¡ ¡

Synthesis ¡Approach ¡

IR ¡Target ¡

  • Binary ¡Analysis ¡

Platform ¡(BAP) ¡IR ¡ ¡ ¡ ¡

slide-57
SLIDE 57

57 ¡

Na?ve ¡Behavior ¡

  • I/O ¡pairs ¡from ¡

native ¡execution ¡

  • QEMU ¡and ¡PIN ¡

traces ¡ ¡ ¡

Synthesis ¡Approach ¡

IR ¡Target ¡

  • Binary ¡Analysis ¡

Platform ¡(BAP) ¡IR ¡

  • IR ¡Interpreter

¡ ¡ ¡

slide-58
SLIDE 58

58 ¡

Na?ve ¡Behavior ¡

Synthesis ¡Approach ¡

IR ¡Target ¡

  • Binary ¡Analysis ¡

Platform ¡(BAP) ¡IR ¡

  • IR ¡Interpreter

¡ ¡ ¡

  • I/O ¡pairs ¡from ¡

native ¡execution ¡

  • QEMU ¡and ¡PIN ¡

traces ¡ ¡ ¡

slide-59
SLIDE 59

59 ¡

Synthesis ¡Approach ¡

slide-60
SLIDE 60

60 ¡

Synthesis ¡Approach ¡

Execution ¡state ¡ Execution ¡state ¡

slide-61
SLIDE 61

61 ¡

Synthesis ¡Approach ¡

Execution ¡state ¡ Instruction ¡

slide-62
SLIDE 62

62 ¡

Synthesis ¡Approach ¡

Execution ¡state ¡ Events ¡from ¡execution ¡

slide-63
SLIDE 63

63 ¡

Synthesis ¡Approach ¡

Execution ¡state ¡ Events ¡from ¡execution ¡

slide-64
SLIDE 64

64 ¡

Inferring ¡Seman?cs ¡from ¡I/O ¡pairs ¡

add ¡R3, ¡R0 ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡

slide-65
SLIDE 65

65 ¡

Inferring ¡Seman?cs ¡from ¡I/O ¡pairs ¡

add ¡R3, ¡R0 ¡ Na?ve ¡Instruc?on ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

Execu?on ¡

Input ¡ Output ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

SOURCE ¡

slide-66
SLIDE 66

66 ¡

Inferring ¡Seman?cs ¡from ¡I/O ¡pairs ¡

add ¡R3, ¡R0 ¡ Na?ve ¡Instruc?on ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

Execu?on ¡

Input ¡ Output ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

SOURCE ¡

slide-67
SLIDE 67

67 ¡

Synthesizing ¡Transla?on ¡

?? ¡ IR ¡Instruc?on ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

Execu?on ¡

Input ¡ Output ¡ TARGET ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

slide-68
SLIDE 68

68 ¡

Synthesizing ¡Transla?on ¡

R3, ¡R0, ¡R3 ¡ IR ¡Instruc?on ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

Execu?on ¡

Input ¡ Output ¡ TARGET ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

slide-69
SLIDE 69

69 ¡

Syntax-­‑guided ¡Synthesis ¡

R3, ¡R0, ¡R3 ¡ IR ¡Instruc?on ¡

_ ¡:= ¡_ ¡+ ¡_ ¡

TARGET ¡

slide-70
SLIDE 70

70 ¡

Syntax-­‑guided ¡Synthesis ¡

R3, ¡R0, ¡R3 ¡ IR ¡Instruc?on ¡

Sketch ¡Templates ¡

_ ¡:= ¡_ ¡+ ¡_ ¡ _ ¡:= ¡_ ¡-­‑ ¡_ ¡ _ ¡:= ¡_ ¡* ¡_ ¡ _ ¡:= ¡_ ¡<< ¡_ ¡ … ¡ R3 ¡:= ¡R0 ¡+ ¡R3 ¡ R3 ¡:= ¡R0 ¡-­‑ ¡R3 ¡ R3 ¡:= ¡R0 ¡* ¡R3 ¡ R3 ¡:= ¡R0 ¡<< ¡R3 ¡ … ¡ _ ¡:= ¡_ ¡+ ¡_ ¡

TARGET ¡

slide-71
SLIDE 71

71 ¡

Syntax-­‑guided ¡Synthesis ¡

R3, ¡R0, ¡R3 ¡ IR ¡Instruc?on ¡

Sketch ¡Templates ¡

_ ¡:= ¡_ ¡+ ¡_ ¡ _ ¡:= ¡_ ¡-­‑ ¡_ ¡ _ ¡:= ¡_ ¡* ¡_ ¡ _ ¡:= ¡_ ¡<< ¡_ ¡ … ¡ R3 ¡:= ¡R0 ¡+ ¡R3 ¡ R3 ¡:= ¡R0 ¡-­‑ ¡R3 ¡ R3 ¡:= ¡R0 ¡* ¡R3 ¡ R3 ¡:= ¡R0 ¡<< ¡R3 ¡ … ¡ _ ¡:= ¡_ ¡+ ¡_ ¡

TARGET ¡ Exhaustive ¡Enumeration ¡

slide-72
SLIDE 72

72 ¡

Syntax-­‑guided ¡Synthesis ¡

R3, ¡R0, ¡R3 ¡ IR ¡Instruc?on ¡

Sketch ¡Templates ¡

_ ¡:= ¡_ ¡+ ¡_ ¡ _ ¡:= ¡_ ¡-­‑ ¡_ ¡ _ ¡:= ¡_ ¡* ¡_ ¡ _ ¡:= ¡_ ¡<< ¡_ ¡ … ¡ R3 ¡:= ¡R0 ¡+ ¡R3 ¡ R3 ¡:= ¡R0 ¡-­‑ ¡R3 ¡ R3 ¡:= ¡R0 ¡* ¡R3 ¡ R3 ¡:= ¡R0 ¡<< ¡R3 ¡ … ¡ _ ¡:= ¡_ ¡+ ¡_ ¡

TARGET ¡ Exhaustive ¡Enumeration ¡ Permute ¡adjacent ¡operands ¡

slide-73
SLIDE 73

73 ¡

R3 ¡:= ¡R0 ¡+ ¡R3 ¡ IR ¡Instruc?on ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

IR ¡Interpreter ¡

Input ¡ Output ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

Syntax-­‑guided ¡Synthesis ¡

TARGET ¡

slide-74
SLIDE 74

74 ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

IR ¡Interpreter ¡

Input ¡ Output ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

Na?ve ¡Execu?on ¡

Input ¡ Expected ¡Output ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

Syntax-­‑guided ¡Synthesis ¡

slide-75
SLIDE 75

75 ¡

R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

IR ¡Interpreter ¡

Input ¡ Expected ¡Output ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

TARGET ¡

Valida?ng ¡Correctness ¡

slide-76
SLIDE 76

76 ¡

R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡

R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡

IR ¡Interpreter ¡

Input ¡ Expected ¡Output ¡

R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡

Oops… ¡

TARGET ¡

Valida?ng ¡Correctness ¡

slide-77
SLIDE 77

77 ¡

R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡

Oops… ¡

TARGET ¡

Valida?ng ¡Correctness ¡

slide-78
SLIDE 78

78 ¡

R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡

R3 ¡= ¡3 ¡ R0 ¡= ¡2 ¡

Na?ve ¡Execu?on ¡

Input ¡ Expected ¡Output ¡

R3 ¡= ¡5 ¡ R0 ¡= ¡2 ¡

TARGET ¡

Valida?ng ¡Correctness ¡

slide-79
SLIDE 79

79 ¡

R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡

R3 ¡= ¡3 ¡ R0 ¡= ¡2 ¡

Na?ve ¡Execu?on ¡

Input ¡ Expected ¡Output ¡

R3 ¡= ¡5 ¡ R0 ¡= ¡2 ¡

TARGET ¡

Valida?ng ¡Correctness ¡

R3 ¡= ¡6 ¡

slide-80
SLIDE 80

80 ¡

R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡

R3 ¡= ¡3 ¡ R0 ¡= ¡2 ¡

Na?ve ¡Execu?on ¡

Input ¡ Expected ¡Output ¡

R3 ¡= ¡5 ¡ R0 ¡= ¡2 ¡ Invalidate ¡ ¡ sketch ¡

TARGET ¡

Valida?ng ¡Correctness ¡

R3 ¡= ¡6 ¡

slide-81
SLIDE 81

81 ¡

Li/er ¡Synthesis ¡System ¡

SKETCHES ¡ SOURCE ¡ Programs ¡ LEARN ¡ SKETCHES ¡ SYNTHESIS ¡ LOOP ¡ TARGET ¡ Programs ¡ NATIVE ¡ EXECUTION ¡ TRACES ¡ TARGET ¡ DISASSEMBLER ¡ TARGET ¡ LIFTER ¡

slide-82
SLIDE 82

82 ¡

Experimental ¡Setup ¡

slide-83
SLIDE 83

83 ¡

Experimental ¡Setup ¡

  • Synthesize ¡unsupported ¡lifter ¡target ¡(MIPS) ¡
slide-84
SLIDE 84

84 ¡

Experimental ¡Setup ¡

  • Synthesize ¡unsupported ¡lifter ¡target ¡(MIPS) ¡
  • Collect ¡dynamic ¡traces ¡from ¡arithmetic-­‑

heavy ¡benchmark ¡

– 5 ¡Hacker’s ¡delight ¡programs ¡

slide-85
SLIDE 85

85 ¡

Experimental ¡Setup ¡

  • Synthesize ¡unsupported ¡lifter ¡target ¡(MIPS) ¡
  • Collect ¡dynamic ¡traces ¡from ¡arithmetic-­‑

heavy ¡benchmark ¡

– 5 ¡Hacker’s ¡delight ¡programs ¡

  • Mine ¡IR ¡sketches ¡from ¡Coreutils, ¡lifted ¡from ¡

ARM ¡and ¡x86 ¡

slide-86
SLIDE 86

86 ¡

Results: ¡Analysis ¡Reuse ¡

slide-87
SLIDE 87

87 ¡

Results: ¡Analysis ¡Reuse ¡

  • Taint ¡analysis ¡for ¡warn-­‑unused-­‑result ¡bugs ¡
slide-88
SLIDE 88

88 ¡

Results: ¡Analysis ¡Reuse ¡

  • Taint ¡analysis ¡for ¡warn-­‑unused-­‑result ¡bugs ¡

– Forget ¡to ¡check ¡memory ¡is ¡allocated ¡ – Forget ¡to ¡check ¡privileges ¡are ¡dropped ¡ ¡

slide-89
SLIDE 89

89 ¡

Results: ¡Analysis ¡Reuse ¡

  • Taint ¡analysis ¡for ¡warn-­‑unused-­‑result ¡bugs ¡

– Forget ¡to ¡check ¡memory ¡is ¡allocated ¡ – Forget ¡to ¡check ¡privileges ¡are ¡dropped ¡ ¡

  • Ran ¡on ¡30 ¡binaries ¡of ¡COTS ¡D-­‑Link ¡router ¡ ¡
slide-90
SLIDE 90

90 ¡

Results: ¡Analysis ¡Reuse ¡

  • Taint ¡analysis ¡for ¡warn-­‑unused-­‑result ¡bugs ¡

– Forget ¡to ¡check ¡memory ¡is ¡allocated ¡ – Forget ¡to ¡check ¡privileges ¡are ¡dropped ¡ ¡

  • Ran ¡on ¡30 ¡binaries ¡of ¡COTS ¡D-­‑Link ¡router ¡ ¡
  • 29 ¡bugs, ¡2 ¡false ¡positives ¡
slide-91
SLIDE 91

91 ¡

Results: ¡Analysis ¡Reuse ¡

Name ¡ # ¡ Func?ons ¡ pppd ¡ 1 ¡ fwrite ¡ iptables ¡ 3 ¡ fwrite ¡ rdnssd ¡ 1 ¡ setsockopt ¡ ntpclient ¡ 1 ¡ send ¡ speedtest ¡ 2 ¡ system, ¡fgets ¡ ?mer ¡ 2 ¡ read, ¡shutdown ¡ wakeOnLanProxy ¡ 1 ¡ shutdown ¡ wcnd ¡ 8 ¡ system ¡

slide-92
SLIDE 92

92 ¡

Results: ¡Analysis ¡Reuse ¡

Name ¡ # ¡ Func?ons ¡ pppd ¡ 1 ¡ fwrite ¡ iptables ¡ 3 ¡ fwrite ¡ rdnssd ¡ 1 ¡ setsockopt ¡ ntpclient ¡ 1 ¡ send ¡ speedtest ¡ 2 ¡ system, ¡fgets ¡ ?mer ¡ 2 ¡ read, ¡shutdown ¡ wakeOnLanProxy ¡ 1 ¡ shutdown ¡ wcnd ¡ 8 ¡ system ¡

slide-93
SLIDE 93

93 ¡

Results: ¡Analysis ¡Reuse ¡

Name ¡ # ¡ Func?ons ¡ pppd ¡ 1 ¡ fwrite ¡ iptables ¡ 3 ¡ fwrite ¡ rdnssd ¡ 1 ¡ setsockopt ¡ ntpclient ¡ 1 ¡ send ¡ speedtest ¡ 2 ¡ system, ¡fgets ¡ ?mer ¡ 2 ¡ read, ¡shutdown ¡ wakeOnLanProxy ¡ 1 ¡ shutdown ¡ wcnd ¡ 8 ¡ system ¡

No ¡false ¡positives ¡on ¡OpenSSL ¡

slide-94
SLIDE 94

94 ¡

Results: ¡Synthesis ¡

slide-95
SLIDE 95

95 ¡

Results: ¡Synthesis ¡

  • End-­‑to-­‑end ¡synthesis ¡takes ¡58 ¡seconds ¡

– mining ¡sketches, ¡processing ¡traces, ¡and ¡lifter ¡ synthesis ¡

  • 29 ¡sketches ¡per ¡instruction, ¡on ¡average ¡

– Synthesis ¡converges ¡after ¡2 ¡input ¡output ¡pairs, ¡on ¡ average ¡

¡

  • Lifts ¡84.8% ¡of ¡native ¡instructions. ¡

– Missed ¡example: ¡“load ¡upper ¡immediate” ¡

slide-96
SLIDE 96

96 ¡

Generalizing ¡across ¡Architectures ¡

slide-97
SLIDE 97

97 ¡

Generalizing ¡across ¡Architectures ¡

  • IR ¡Sketches ¡mined ¡from ¡ARM ¡and ¡x86 ¡are ¡

common ¡to ¡both ¡

  • Similar ¡MIPS ¡accuracy ¡from ¡either ¡ARM ¡or ¡x86 ¡

sketches ¡

% ¡ ARM-­‑IR ¡ % ¡ X86-­‑IR ¡ 20.9 ¡ ¡ ¡_v ¡:= ¡_v ¡ 11.9 ¡ _v ¡:= ¡_i ¡ 14.5 ¡ ¡ ¡_v ¡:= ¡_i ¡ 8.6 ¡ jmp ¡_i ¡ 8.9 ¡ ¡ ¡jmp ¡_i ¡ 5.1 ¡ ¡_v ¡:= ¡mem[_v ¡+ ¡_i] ¡ 7.0 ¡ ¡ ¡_v ¡:= ¡mem[_v ¡+ ¡_i] ¡ 4.4 ¡ mem[_v ¡+ ¡_i] ¡:= ¡_v ¡ 5.6 ¡ ¡ ¡_v ¡:= ¡_v ¡= ¡_i ¡ 4.2 ¡ _v ¡:= ¡_v ¡= ¡_i ¡ 5.6 ¡ ¡ ¡_v ¡:= ¡hi ¡: ¡1[_v] ¡ 4.2 ¡ _v ¡:= ¡hi ¡: ¡1[_v] ¡ 5.5 ¡ mem[_v ¡+ ¡_i] ¡:= ¡_v ¡ 4.0 ¡ mem[_v ¡+ ¡_i] ¡:= ¡_v ¡ 4.6 ¡ ¡ ¡ ¡_v ¡:= ¡_v ¡-­‑ ¡_i ¡ 3.9 ¡ _v ¡:= ¡_v ¡-­‑ ¡_i ¡

slide-98
SLIDE 98

98 ¡

Discussion ¡

  • How ¡good ¡“out-­‑of-­‑box”? ¡
  • Improve ¡recovery ¡with ¡nondeterministic ¡

sketch ¡search ¡and ¡generation ¡

  • Expand ¡to ¡more ¡architectures ¡

– SPARC, ¡PPC, ¡… ¡

  • Complement ¡automatic ¡synthesis ¡with ¡

(reduced) ¡manual ¡effort ¡

– Verify ¡and ¡3ix ¡manual ¡translation ¡

slide-99
SLIDE 99

99 ¡

Summary ¡

Verify ¡with ¡Dynamic ¡Traces ¡ Analysis ¡Reuse ¡for ¡Previously ¡ Unsupported ¡Instruction ¡Set ¡ Lifter ¡Synthesis ¡ Learn ¡Sketches ¡