ConTExT
A Generic Approach for Mitigating Spectre
Michael Schwarz, Moritz Lipp, Claudio Canella, Robert Schilling, Florian Kargl, Daniel Gruss February 26, 2020
Graz University of Technology
ConTExT A Generic Approach for Mitigating Spectre Michael Schwarz, - - PowerPoint PPT Presentation
ConTExT A Generic Approach for Mitigating Spectre Michael Schwarz, Moritz Lipp, Claudio Canella, Robert Schilling, Florian Kargl, Daniel Gruss February 26, 2020 Graz University of Technology Transient Execution Attacks www.tugraz.at 1
Michael Schwarz, Moritz Lipp, Claudio Canella, Robert Schilling, Florian Kargl, Daniel Gruss February 26, 2020
Graz University of Technology
www.tugraz.at 1 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at 1 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at 1 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at 1 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at 1 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at 1 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
Transient cause
2 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
Transient cause Meltdown-type Meltdown-NM-REG Meltdown-AC Meltdown-DE Meltdown-PF Meltdown-UD Meltdown-SS Meltdown-BR Meltdown-GP Meltdown-MCA Meltdown-AC-LFB Meltdown-AC-LP Meltdown-US Meltdown-P Meltdown-RW Meltdown-PK Meltdown-SM-SB Meltdown-MPX Meltdown-BND Meltdown-CPL-REG Meltdown-NC-SB Meltdown-AVX Meltdown-AD Meltdown-TAA Meltdown-PRM-LFB Meltdown-UC-LFB Meltdown-US-L1 Meltdown-US-LFB Meltdown-US-SB Meltdown-P-L1 Meltdown-P-LFB Meltdown-P-SB Meltdown-P-LP Meltdown-PK-L1 Meltdown-PK-SB Meltdown-AVX-SB Meltdown-AVX-LP Meltdown-AD-LFB Meltdown-AD-SB Meltdown-TAA-LFB Meltdown-TAA-LP Meltdown-TAA-SB
2 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
Transient cause Meltdown-type Meltdown-NM-REG Meltdown-AC Meltdown-DE Meltdown-PF Meltdown-UD Meltdown-SS Meltdown-BR Meltdown-GP Meltdown-MCA Spectre-type Spectre-PHT Spectre-BTB Spectre-RSB Spectre-STL PHT-CA-IP PHT-CA-OP PHT-SA-IP PHT-SA-OP BTB-CA-IP BTB-CA-OP BTB-SA-IP BTB-SA-OP RSB-CA-IP RSB-CA-OP RSB-SA-IP RSB-SA-OP Cross-address-space Same-address-space Cross-address-space Same-address-space Cross-address-space Same-address-space Meltdown-AC-LFB Meltdown-AC-LP Meltdown-US Meltdown-P Meltdown-RW Meltdown-PK Meltdown-SM-SB Meltdown-MPX Meltdown-BND Meltdown-CPL-REG Meltdown-NC-SB Meltdown-AVX Meltdown-AD Meltdown-TAA Meltdown-PRM-LFB Meltdown-UC-LFB Meltdown-US-L1 Meltdown-US-LFB Meltdown-US-SB Meltdown-P-L1 Meltdown-P-LFB Meltdown-P-SB Meltdown-P-LP Meltdown-PK-L1 Meltdown-PK-SB Meltdown-AVX-SB Meltdown-AVX-LP Meltdown-AD-LFB Meltdown-AD-SB Meltdown-TAA-LFB Meltdown-TAA-LP Meltdown-TAA-SB
2 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
Transient cause Meltdown-type Meltdown-NM-REG Meltdown-AC Meltdown-DE Meltdown-PF Meltdown-UD Meltdown-SS Meltdown-BR Meltdown-GP Meltdown-MCA Spectre-type Spectre-PHT Spectre-BTB Spectre-RSB Spectre-STL PHT-CA-IP PHT-CA-OP PHT-SA-IP PHT-SA-OP BTB-CA-IP BTB-CA-OP BTB-SA-IP BTB-SA-OP RSB-CA-IP RSB-CA-OP RSB-SA-IP RSB-SA-OP Cross-address-space Same-address-space Cross-address-space Same-address-space Cross-address-space Same-address-space Meltdown-AC-LFB Meltdown-AC-LP Meltdown-US Meltdown-P Meltdown-RW Meltdown-PK Meltdown-SM-SB Meltdown-MPX Meltdown-BND Meltdown-CPL-REG Meltdown-NC-SB Meltdown-AVX Meltdown-AD Meltdown-TAA Meltdown-PRM-LFB Meltdown-UC-LFB Meltdown-US-L1 Meltdown-US-LFB Meltdown-US-SB Meltdown-P-L1 Meltdown-P-LFB Meltdown-P-SB Meltdown-P-LP Meltdown-PK-L1 Meltdown-PK-SB Meltdown-AVX-SB Meltdown-AVX-LP Meltdown-AD-LFB Meltdown-AD-SB Meltdown-TAA-LFB Meltdown-TAA-LP Meltdown-TAA-SB
2 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
Spectre-type Spectre-PHT Spectre-BTB Spectre-RSB Spectre-STL PHT-CA-IP PHT-CA-OP PHT-SA-IP PHT-SA-OP BTB-CA-IP BTB-CA-OP BTB-SA-IP BTB-SA-OP RSB-CA-IP RSB-CA-OP RSB-SA-IP RSB-SA-OP Cross-address-space Same-address-space Cross-address-space Same-address-space Cross-address-space Same-address-space
3 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
4 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
4 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
4 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
possibly architectural
4 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
possibly architectural
4 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
possibly architectural
flush pipeline
prediction
4 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
possibly architectural
flush pipeline
prediction
4 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at 5 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
6 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
· · · array[0] array[1] array[2] array[3] Speculate
7 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8)
8 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check
8 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Access out-of-bounds array[x]
8 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Access out-of-bounds array[x] Secret in rax
8 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Access out-of-bounds array[x] Secret in rax Access secret-dependent memory location
8 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
9 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed1 cmp rdi, .array len jbe .else lfence stall mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8)
10 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed1 cmp rdi, .array len jbe .else lfence stall mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Stop speculation
10 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed1 cmp rdi, .array len jbe .else lfence stall mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Stop speculation Cannot access out-of-bounds array[x]
10 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
11 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
11 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
11 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
12 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
12 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
12 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
13 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
13 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
13 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
14 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
14 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
15 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8)
16 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check
16 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Access out-of-bounds array[x]
16 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Access out-of-bounds array[x] Secret in rax, no operations on secret
16 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Access out-of-bounds array[x] Secret in rax, no operations on secret Independent operations continue out-of-order
16 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
17 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
17 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
17 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
17 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
18 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
18 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
18 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
18 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
18 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8)
19 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check
19 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Out-of-bounds access array[x] stalls
19 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Out-of-bounds access array[x] stalls Dependent operations stall
19 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
not executed cmp rdi, .array len jbe .else mov (rax + rdi),al shl 12,rax and 0xff000,eax mov (rdx + rax),al mov 0,rax retq mov rax,(rsp + 8) Bounds check Out-of-bounds access array[x] stalls Dependent operations stall Independent operations continue out-of-order
19 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
char oracle[256 * 4096]; // nospec for ConTExT-light char /*nospec*/ secret = 'X'; if(speculate()) { // LFENCE here for mitigation
}
66 68 70 72 74 76 78 80 82 84 86 88 90 100 200 300
No secret 0x45 Secret 0x58
Page of oracle Latency [cycles]
unprotected
20 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
char oracle[256 * 4096]; // nospec for ConTExT-light char /*nospec*/ secret = 'X'; if(speculate()) { asm volatile("lfence");
}
66 68 70 72 74 76 78 80 82 84 86 88 90 100 200 300
No secret 0x45 Secret 0x58
Page of oracle Latency [cycles]
unprotected lfence
20 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
char oracle[256 * 4096]; // nospec for ConTExT-light char nospec secret = 'X'; if(speculate()) { // LFENCE here for mitigation
}
66 68 70 72 74 76 78 80 82 84 86 88 90 100 200 300
No secret 0x45 Secret 0x58
Page of oracle Latency [cycles]
unprotected lfence ConTExT
20 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
21 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
21 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
21 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
21 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
22 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
23 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
23 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
Michael Schwarz, Moritz Lipp, Claudio Canella, Robert Schilling, Florian Kargl, Daniel Gruss. ConTExT: A Generic Approach for Mitigating Spectre. 24 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
25 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
25 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
25 Michael Schwarz (@misc0110) et al. — Graz University of Technology
www.tugraz.at
25 Michael Schwarz (@misc0110) et al. — Graz University of Technology
Michael Schwarz, Moritz Lipp, Claudio Canella, Robert Schilling, Florian Kargl, Daniel Gruss February 26, 2020
Graz University of Technology
www.tugraz.at
We thank our anonymous reviewers for their comments and suggestions that helped improving the
Union’s Horizon 2020 research and innovation programme (grant agreement No 681402). It was also supported by the Austrian Research Promotion Agency (FFG) via the K-project DeSSnet, which is funded in the context of COMET - Competence Centers for Excellent Technologies by BMVIT, BMWFW, Styria and Carinthia. This work has additionally been supported by the Austrian Research Promotion Agency (FFG) via the project ESPRESSO, which is funded by the Province of Styria and the Business Promotion Agencies of Styria and Carinthia. This work has also been supported by the Austrian Research Promotion Agency (FFG) via the competence center Know-Center (grant number 844595), which is funded in the context of COMET – Competence Centers for Excellent Technologies by BMVIT, BMWFW, and Styria. Additional funding was provided by generous gifts from ARM and
the authors and do not necessarily reflect the views of the funding parties.
inaccessible by speculative instructions. US Patent App. 16/022,274. 2019.
Channel Attacks. 2019.
A Generic Approach for Mitigating Spectre. In: NDSS. 2020.