Cross-Architecture Li/er Synthesis Rijnard van Tonder and - - PowerPoint PPT Presentation
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
Cross-‑Architecture ¡Li/er ¡Synthesis ¡
Rijnard ¡van ¡Tonder ¡and ¡Claire ¡Le ¡Goues ¡ ¡ ¡
3 ¡
What ¡is ¡a ¡Li/er? ¡
4 ¡
What ¡is ¡a ¡Li/er? ¡
x86 ¡ ARM ¡ … ¡
Lower ¡level ¡code ¡
5 ¡
What ¡is ¡a ¡Li/er? ¡
x86 ¡ ARM ¡ … ¡
Lower ¡level ¡code ¡ Architecture-‑speci3ic ¡
6 ¡
What ¡is ¡a ¡Li/er? ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
7 ¡
What ¡is ¡a ¡Li/er? ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
Higher ¡level ¡code ¡
8 ¡
What ¡is ¡a ¡Li/er? ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
Higher ¡level ¡code ¡ Architecture-‑agnostic ¡
9 ¡
Why ¡Li/ers? ¡
10 ¡
Why ¡Li/ers? ¡
- Binary ¡analysis ¡
11 ¡
Why ¡Li/ers? ¡
- Binary ¡analysis ¡
- Simpler ¡semantic ¡abstraction ¡
– E.g., ¡symbolic ¡execution ¡
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 ¡
13 ¡
Compilers ¡and ¡Decompilers ¡
- Compilers ¡lose ¡information ¡
– Translation ¡is ¡not ¡a ¡bijection ¡ ¡
14 ¡
Compilers ¡and ¡Decompilers ¡
- Compilers ¡lose ¡information ¡
– Translation ¡is ¡not ¡a ¡bijection ¡
- Decompilers ¡recover ¡more ¡features ¡
– Often ¡architecture-‑speci3ic ¡(e.g., ¡ABI) ¡
15 ¡
The ¡Problem: ¡ Transla?ng ¡Mul?ple ¡Architectures ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
Manual ¡
16 ¡
The ¡Problem: ¡ Transla?ng ¡Mul?ple ¡Architectures ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
Manual ¡ 1000s ¡of ¡manual ¡pages ¡
17 ¡
Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
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] ¡
19 ¡
Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
Cross-‑Architecture ¡reuse ¡
20 ¡
Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
Bug-‑3inding ¡Analyses ¡“for ¡free” ¡
21 ¡
Our ¡Goal: ¡ Automate ¡across ¡Architectures ¡
x86 ¡ ARM ¡ … ¡ Intermediate ¡ Representa@on ¡
Bug-‑3inding ¡Analyses ¡“for ¡free” ¡ Data3low ¡framework ¡ VC ¡Generation ¡ Taint ¡analysis ¡
22 ¡
What ¡We ¡Do ¡
23 ¡
What ¡We ¡Do ¡
- IR ¡translation ¡as ¡a ¡Syntax-‑Guided ¡Synthesis ¡
problem ¡
24 ¡
What ¡We ¡Do ¡
- IR ¡translation ¡as ¡a ¡Syntax-‑Guided ¡Synthesis ¡
problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡
25 ¡
What ¡We ¡Do ¡
- IR ¡translation ¡as ¡a ¡Syntax-‑Guided ¡Synthesis ¡
problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡ ≡ ¡∀x ¡. ¡oracle(x) ¡= ¡P(x) ¡
26 ¡
What ¡We ¡Do ¡
- IR ¡translation ¡as ¡a ¡Syntax-‑Guided ¡Synthesis ¡
problem ¡ ¡∀x ¡. ¡φ(x, ¡P(x)) ¡ ¡ ≡ ¡∀x ¡. ¡oracle(x) ¡= ¡P(x) ¡
Correctness ¡speci3ication ¡
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 ¡
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 ¡
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 ¡
30 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
31 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
add ¡R3, ¡R0 ¡ ARM ¡
32 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡
33 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡ Op ¡codes ¡and ¡register ¡names ¡
34 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
LIFT ¡ add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡ Manual ¡translation ¡rules ¡
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 ¡
36 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ ARM ¡ Na?ve ¡Instruc?on ¡ IR ¡Instruc?on ¡ SOURCE ¡ TARGET ¡
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 ¡
38 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ IR ¡SKETCH ¡
39 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ Create ¡sketches ¡from ¡concrete ¡expressions ¡ IR ¡SKETCH ¡
40 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
- Learn ¡templates ¡from ¡lifter ¡output ¡for ¡a ¡
supported ¡architecture ¡to ¡synthesize ¡one ¡ for ¡an ¡unsupported ¡architecture ¡
41 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ Create ¡sketches ¡from ¡concrete ¡expressions ¡ IR ¡ IR ¡SKETCH ¡
42 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ add ¡$1, ¡$2 ¡ MIPS ¡ IR ¡ IR ¡SKETCH ¡
43 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
R3 ¡:= ¡R3 ¡+ ¡R0 ¡ LIFT ¡ add ¡R3, ¡R0 ¡ _ ¡:= ¡_ ¡+ ¡_ ¡ ARM ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ IR ¡ IR ¡SKETCH ¡
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 ¡
45 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
_ ¡:= ¡_ ¡+ ¡_ ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ IR ¡SKETCH ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡
46 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
_ ¡:= ¡_ ¡+ ¡_ ¡ IR ¡SKETCH ¡ add ¡$1, ¡$2 ¡ MIPS ¡ Unsupported ¡ Architecture ¡ SYNTHESIS ¡ $1 ¡:= ¡$1 ¡+ ¡$2 ¡ IR ¡
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 ¡
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 ¡
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 ¡
50 ¡
Learning ¡Sketch ¡Templates: ¡Example ¡
- Learn ¡templates ¡from ¡lifter ¡output ¡for ¡a ¡
supported ¡architecture ¡to ¡synthesize ¡one ¡ for ¡an ¡unsupported ¡architecture ¡
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 ¡
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 ¡
53 ¡
Synthesis ¡Approach ¡
54 ¡
Na?ve ¡Behavior ¡
- I/O ¡pairs ¡from ¡
native ¡execution ¡ ¡
Synthesis ¡Approach ¡
55 ¡
Na?ve ¡Behavior ¡
- I/O ¡pairs ¡from ¡
native ¡execution ¡
- QEMU ¡and ¡PIN ¡
traces ¡ ¡ ¡
Synthesis ¡Approach ¡
56 ¡
Na?ve ¡Behavior ¡
- I/O ¡pairs ¡from ¡
native ¡execution ¡
- QEMU ¡and ¡PIN ¡
traces ¡ ¡ ¡
Synthesis ¡Approach ¡
IR ¡Target ¡
- Binary ¡Analysis ¡
Platform ¡(BAP) ¡IR ¡ ¡ ¡ ¡
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
¡ ¡ ¡
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 ¡ ¡ ¡
59 ¡
Synthesis ¡Approach ¡
60 ¡
Synthesis ¡Approach ¡
Execution ¡state ¡ Execution ¡state ¡
61 ¡
Synthesis ¡Approach ¡
Execution ¡state ¡ Instruction ¡
62 ¡
Synthesis ¡Approach ¡
Execution ¡state ¡ Events ¡from ¡execution ¡
63 ¡
Synthesis ¡Approach ¡
Execution ¡state ¡ Events ¡from ¡execution ¡
64 ¡
Inferring ¡Seman?cs ¡from ¡I/O ¡pairs ¡
add ¡R3, ¡R0 ¡ Na?ve ¡Instruc?on ¡ SOURCE ¡
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 ¡
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 ¡
67 ¡
Synthesizing ¡Transla?on ¡
?? ¡ IR ¡Instruc?on ¡
R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡
Execu?on ¡
Input ¡ Output ¡ TARGET ¡
R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡
68 ¡
Synthesizing ¡Transla?on ¡
R3, ¡R0, ¡R3 ¡ IR ¡Instruc?on ¡
R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡
Execu?on ¡
Input ¡ Output ¡ TARGET ¡
R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡
69 ¡
Syntax-‑guided ¡Synthesis ¡
R3, ¡R0, ¡R3 ¡ IR ¡Instruc?on ¡
_ ¡:= ¡_ ¡+ ¡_ ¡
TARGET ¡
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 ¡
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 ¡
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 ¡
73 ¡
R3 ¡:= ¡R0 ¡+ ¡R3 ¡ IR ¡Instruc?on ¡
R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡
IR ¡Interpreter ¡
Input ¡ Output ¡
R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡
Syntax-‑guided ¡Synthesis ¡
TARGET ¡
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 ¡
75 ¡
R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡
R3 ¡= ¡2 ¡ R0 ¡= ¡2 ¡
IR ¡Interpreter ¡
Input ¡ Expected ¡Output ¡
R3 ¡= ¡4 ¡ R0 ¡= ¡2 ¡
TARGET ¡
Valida?ng ¡Correctness ¡
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 ¡
77 ¡
R3 ¡:= ¡R0 ¡* ¡R3 ¡ IR ¡Instruc?on ¡
Oops… ¡
TARGET ¡
Valida?ng ¡Correctness ¡
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 ¡
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 ¡
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 ¡
81 ¡
Li/er ¡Synthesis ¡System ¡
SKETCHES ¡ SOURCE ¡ Programs ¡ LEARN ¡ SKETCHES ¡ SYNTHESIS ¡ LOOP ¡ TARGET ¡ Programs ¡ NATIVE ¡ EXECUTION ¡ TRACES ¡ TARGET ¡ DISASSEMBLER ¡ TARGET ¡ LIFTER ¡
82 ¡
Experimental ¡Setup ¡
83 ¡
Experimental ¡Setup ¡
- Synthesize ¡unsupported ¡lifter ¡target ¡(MIPS) ¡
84 ¡
Experimental ¡Setup ¡
- Synthesize ¡unsupported ¡lifter ¡target ¡(MIPS) ¡
- Collect ¡dynamic ¡traces ¡from ¡arithmetic-‑
heavy ¡benchmark ¡
– 5 ¡Hacker’s ¡delight ¡programs ¡
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 ¡
86 ¡
Results: ¡Analysis ¡Reuse ¡
87 ¡
Results: ¡Analysis ¡Reuse ¡
- Taint ¡analysis ¡for ¡warn-‑unused-‑result ¡bugs ¡
88 ¡
Results: ¡Analysis ¡Reuse ¡
- Taint ¡analysis ¡for ¡warn-‑unused-‑result ¡bugs ¡
– Forget ¡to ¡check ¡memory ¡is ¡allocated ¡ – Forget ¡to ¡check ¡privileges ¡are ¡dropped ¡ ¡
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 ¡ ¡
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 ¡
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 ¡
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 ¡
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 ¡
94 ¡
Results: ¡Synthesis ¡
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” ¡
96 ¡
Generalizing ¡across ¡Architectures ¡
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 ¡
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 ¡
99 ¡
Summary ¡
Verify ¡with ¡Dynamic ¡Traces ¡ Analysis ¡Reuse ¡for ¡Previously ¡ Unsupported ¡Instruction ¡Set ¡ Lifter ¡Synthesis ¡ Learn ¡Sketches ¡