Br Breaking Kern rnel Ad Address ss Space La Layout Randomization (KASLR LR) wi with th Intel TSX
Yeongjin Jang, Sangho Lee, and Taesoo Kim Georgia Institute of Technology
Br Breaking Kern rnel Ad Address ss Space La Layout - - PowerPoint PPT Presentation
Br Breaking Kern rnel Ad Address ss Space La Layout Randomization (KASLR LR) wi with th Intel TSX Yeongjin Jang , Sangho Lee, and Taesoo Kim Georgia Institute of Technology Kernel Address Space Layout Randomization (KASLR) A
Yeongjin Jang, Sangho Lee, and Taesoo Kim Georgia Institute of Technology
2
3
4
5
1st Boot
2nd Boot
6
1st Boot
7
8
9
TLB
Virtual Address Hit Miss
10
TLB
Virtual Address Hit Miss Mapped address generate page fault quicker!
11
TLB
Virtual Address Hit Miss Mapped address generate page fault quicker! Unmapped address takes ~40 cycles more for page table walk
12
TLB
Virtual Address Hit Miss Mapped address generate page fault quicker! Unmapped address takes ~40 cycles more for page table walk
13
TLB
Virtual Address Hit Miss Mapped address generate page fault quicker! Unmapped address takes ~40 cycles more for page table walk
14
TLB
Virtual Address Hit Miss Mapped address generate page fault quicker! Unmapped address takes ~40 cycles more for page table walk
15
TLB
Virtual Address Hit Miss Mapped address generate page fault quicker! Unmapped address takes ~40 cycles more for page table walk
16
TLB
Virtual Address Hit Miss Mapped address generate page fault quicker! Unmapped address takes ~40 cycles more for page table walk
17
18
19
Mapped Unmapped
20
User CPU OS Exception Handling OS Noise
User Execution CPU Exception OS Execution OS Handling Noise
T L B
TLB Side Channel
CPU T L B
Timing Side Channel (~40 cycles) OS Noise Fault Handling Noise is too much! Measured Time (~4000 cycles) OS Noise (~100 cycles)
21
User CPU OS Exception Handling OS Noise
User Execution CPU Exception OS Execution OS Handling Noise
T L B
TLB Side Channel
CPU T L B
Timing Side Channel (~40 cycles) OS Noise Fault Handling Noise is too much! Measured Time (~4000 cycles) OS Noise (~100 cycles)
22
23
24
25
(retry, get back to traditional lock, etc.)
26
write/L3 read)
Run If Transaction Aborts
27
Run If Transaction Aborts
28
29
User CPU OS Exception Handling OS Noise
User Execution CPU Exception OS Execution OS Handling Noise
T L B
TLB Side Channel
Measured Time (~ 4000 cycles)
30
User CPU OS Exception Handling OS Noise
User Execution CPU Exception OS Execution OS Handling Noise
T L B
TLB Side Channel
Timing Side Channel (~ 40 cycles) Not involving OS, Less noisy! Measured Time (~ 4000 cycles) User CPU T L B Measured Time (~ 180 cycles)
31
32
the TSX region (always aborts)
33
the TSX region (always aborts)
34
the TSX region (always aborts)
Processor directly calls the handler OS handling path is not involved
35
Processor Mapped Page Unmapped Page i7-6700K (4.0Ghz) 209 240 (+31) i5-6300HQ (2.3Ghz) 164 188 (+24) i7-5600U (2.6Ghz) 149 173 (+24) E3-1271v3 (3.6Ghz) 177 195 (+18)
36
37
Processor Executable Page Non-exec Page i7-6700K (4.0Ghz) 181 226 (+45) i5-6300HQ (2.3Ghz) 142 178 (+36) i7-5600U (2.6Ghz) 134 164 (+30) E3-1271v3 (3.6Ghz) 159 189 (+30)
Clear separation between different mapping status! Mapped Executable
38
Unmapped Non-Executable or Unmapped
39
40
knows the binary file
41
0x4000, and the size of non- executable section is 0x4000, then it is libahci!
X NX X NX 0x4000 0x4000 libahci 0x16000 0x1a000 iwlwifi
42
43
Mapped Page Unmapped Page Description dTLB-loads 3,021,847 3,020,243 dTLB-load-misses
84 2,000,086
TLB-miss on U Observed Timing 209 (fast) 240 (slow)
44
Mapped Page Unmapped Page Description dTLB-loads 3,021,847 3,020,243 dTLB-load-misses
84 2,000,086
TLB-miss on U Observed Timing 209 (fast) 240 (slow)
45
dTLB Probing an unmapped page took 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
46
dTLB Probing an unmapped page took 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
47
dTLB Probing an unmapped page took 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
48
dTLB Probing an unmapped page took 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Page fault!
49
dTLB Probing an unmapped page took 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Page fault!
50
dTLB On the first access, 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
51
dTLB On the first access, 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
52
dTLB On the first access, 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
53
dTLB On the first access, 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Page fault!
54
dTLB On the first access, 240 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Page fault! Cache TLB entry! PTE
55
dTLB On the second access, 209 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table PTE
56
dTLB On the second access, 209 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
PTE
57
dTLB On the second access, 209 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Page fault! dTLB hit PTE
58
dTLB On the second access, 209 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Page fault! dTLB hit
PTE
59
Exec Page Non-exec Page Unmapped Page iTLB-loads (hit)
590
1,000,247 272 iTLB-load-misses
31 12 1,000,175
Observed Timing
181 (fast) 226 (slow) 226 (slow)
60
Exec Page Non-exec Page Unmapped Page iTLB-loads (hit)
590
1,000,247 272 iTLB-load-misses
31 12 1,000,175
Observed Timing
181 (fast) 226 (slow) 226 (slow)
61
Exec Page Non-exec Page Unmapped Page iTLB-loads (hit)
590
1,000,247 272 iTLB-load-misses
31 12 1,000,175
Observed Timing
181 (fast) 226 (slow) 226 (slow)
62
From the patent US 20100138608 A1, registered by Intel Corporation
63
cache (requires TLB access)
From the patent US 20100138608 A1, registered by Intel Corporation
64
From the patent US 20100138608 A1, registered by Intel Corporation
65
micro-ops (RISC-like instruction)
cache (no TLB access)
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
66
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
67
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
68
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Page fault!
69
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Page fault!
70
iTLB On the first access PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table Decoded I-cache
71
iTLB On the first access PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache
72
iTLB On the first access PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache miss
73
iTLB On the first access PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Decoded I-cache miss
74
iTLB On the first access PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Insufficient privilege, fault! Decoded I-cache miss
75
iTLB On the first access PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Insufficient privilege, fault! Decoded I-cache miss PTE Cache TLB
76
iTLB On the first access PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access TLB miss
Insufficient privilege, fault! Decoded I-cache miss PTE Cache TLB uops Cache Decoded Instructions
77
iTLB On the second access, 181 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table Decoded I-cache PTE uops
78
iTLB On the second access, 181 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache PTE uops
79
iTLB On the second access, 181 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Insufficient privilege, fault! Decoded I-cache PTE uops Decoded I-cache hit!
80
iTLB On the second access, 181 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Insufficient privilege, fault! Decoded I-cache PTE uops Decoded I-cache hit!
81
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table Decoded I-cache PTE
82
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache PTE
83
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache miss PTE
84
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache miss PTE Page fault! TLB hit
85
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache miss PTE Page fault! TLB hit
86
87
TLB 0xff01->0x0010, NX Core 1
88
TLB 0xff01->0x0010, NX Core 1
TLB 0xff01->0x0010, X Core 2
No coherency, do not update/invalidate TLB in Core 1
89
TLB 0xff01->0x0010, NX Core 1
TLB 0xff01->0x0010, X Core 2
No coherency, do not update/invalidate TLB in Core 1
90
TLB 0xff01->0x0010, NX Core 1
TLB 0xff01->0x0010, X Core 2
No coherency, do not update/invalidate TLB in Core 1
The page table entry is X, update TLB, then execute!
Execute
91
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table Decoded I-cache PTE
92
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache PTE
93
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache miss PTE
94
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache miss PTE NX, cannot execute! TLB hit
95
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
Decoded I-cache miss PTE NX, cannot execute! TLB hit
96
iTLB On the second access, 226 cycles PML4 PML3 PML3 PML2 PML2 PML2 PML1 PML1 PML1 PTE Page Table
Kernel address access
NX, Page fault! Decoded I-cache miss PTE Cache TLB NX, cannot execute! TLB hit
97
Fast Path (X) Slow Path (NX) Slow Path (U)
page table walk.
Cycles: 181 Cycles: 226 Cycles: 226
98
indirectly (e.g., counting i++;)
99
100
101
102