Beruflich Dokumente
Kultur Dokumente
Daniel Gruss
September 19, 2018
Graz University of Technology
printf("%d", i);
printf("%d", i);
h e miss
Cac
printf("%d", i);
printf("%d", i);
h e miss Req
uest
Cac
printf("%d", i);
printf("%d", i);
h e miss Req
uest
Cac
printf("%d", i);
onse
printf("%d", i); Resp
h e miss Req
uest
Cac
printf("%d", i);
i onse
printf("%d", i); Resp
h e miss Req
uest
Cac
printf("%d", i);
i onse
printf("%d", i); Resp
e hit
Cach
ess,
DRAM acc
slow
h e miss Req
uest
Cac
printf("%d", i);
i onse
printf("%d", i); Resp
e hit
Cach
ess,
DRAM acc
slow
h e miss Req
uest
Cac
printf("%d", i);
i onse
printf("%d", i); Resp
e hit
Cach
o D R A M access,
N
er
much fast
2 Daniel Gruss — Graz University of Technology
Flush+Reload www.tugraz.at
Shared Memory
ATTACKER VICTIM
flush access
access
Shared Memory
ATTACKER VICTIM
ca
flush ch e d access
e d ch
ca
Shared Memory
access
Shared Memory
ATTACKER VICTIM
Shared Memory
ATTACKER VICTIM
flush access
access
Shared Memory
ATTACKER VICTIM
flush access
access
Shared Memory
ATTACKER VICTIM
Shared Memory
ATTACKER VICTIM
Shared Memory
ATTACKER VICTIM
Cache Hits
107
Number of accesses
104
101
107
Number of accesses
104
101
Parallelize
ency
ITLB
L1 Instruction Cache
Predictor
Instruction Queue
MUX
Allocation Queue
µOP µOP µOP µOP
Instructions are
CDB Reorder buffer
µOP µOP µOP µOP µOP µOP µOP µOP
• fetched and decoded in the front-end
Execution Engine
Scheduler
µOP µOP µOP µOP µOP µOP µOP µOP
ALU, FMA, . . .
ALU, AES, . . .
ALU, Vect, . . .
Store data
Load data
Load data
ALU, Branch
AGU
Execution Units
DTLB STLB
L1 Data Cache
L2 Cache
ITLB
L1 Instruction Cache
Predictor
Instruction Queue
MUX
Allocation Queue
µOP µOP µOP µOP
Instructions are
CDB Reorder buffer
µOP µOP µOP µOP µOP µOP µOP µOP
• fetched and decoded in the front-end
Execution Engine
Scheduler
µOP µOP µOP µOP µOP µOP µOP µOP
ALU, Vect, . . .
Store data
Load data
Load data
ALU, Branch
AGU
Execution Units
DTLB STLB
L1 Data Cache
L2 Cache
ITLB
L1 Instruction Cache
Predictor
Instruction Queue
MUX
Allocation Queue
µOP µOP µOP µOP
Instructions are
CDB Reorder buffer
µOP µOP µOP µOP µOP µOP µOP µOP
• fetched and decoded in the front-end
Execution Engine
Scheduler
µOP µOP µOP µOP µOP µOP µOP µOP
ALU, Vect, . . .
Store data
Load data
Load data
ALU, Branch
AGU
DTLB STLB
L1 Data Cache
L2 Cache
segfault at ffffffff81a000e0 ip
0000000000400535
sp 00007 ffce4a80610 error 5 in reader
Adapted code
*( volatile char *) 0;
array [84 * 4096] = 0; // unreachable
Access time
500
[cycles]
400
300
Access time
500
[cycles]
400
300
Flush+Reload again...
Access time
500
[cycles]
400
300
Access time
500
[cycles]
400
300
Access time
500
[cycles]
400
300
Without KAISER:
Shared address space
User memory Kernel memory
0 −1
context switch
Without KAISER:
Shared address space
User memory Kernel memory
0 −1
context switch
With KAISER:
User address space
User memory Not mapped
0 −1
addr. space
switch
context switch Interrupt
dispatcher
1
Jo Van Bulck et al. Foreshadow: Extracting the Keys to the Intel SGX Kingdom with Transient
Out-of-Order Execution. In: USENIX Security Symposium. 2018.
17 Daniel Gruss — Graz University of Technology
L1TF/Foreshadow Demo
Mitigating L1TF/Foreshadow www.tugraz.at
Either:
Either:
• hyperthreading: only schedule mutually trusting threads on
same physical core
Either:
• hyperthreading: only schedule mutually trusting threads on
same physical core
• context switch: flush L1 when switching to guest
Either:
• hyperthreading: only schedule mutually trusting threads on
same physical core
• context switch: flush L1 when switching to guest
Or:
Either:
• hyperthreading: only schedule mutually trusting threads on
same physical core
• context switch: flush L1 when switching to guest
Or:
• disable EPTs
index = 0;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 0;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 0;
if (index < 4)
Speculate
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 0;
if (index < 4)
Execute
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 1;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 1;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 1;
if (index < 4)
Speculate
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 1;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 2;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 2;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 2;
if (index < 4)
Speculate
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 2;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 3;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 3;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 3;
if (index < 4)
Speculate
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 3;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 4;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 4;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 4;
if (index < 4)
Speculate
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 4;
if (index < 4)
Execute
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 5;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 5;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 5;
if (index < 4)
Speculate
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 5;
if (index < 4)
Execute
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 6;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 6;
if (index < 4)
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 6;
if (index < 4)
Speculate
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 1) www.tugraz.at
index = 6;
if (index < 4)
Execute
els
en e
th
Prediction
LUT[data[index] * 4096] 0
21 Daniel Gruss — Graz University of Technology
Spectre (variant 4) www.tugraz.at
index = 0;
index = 0;
index = 0;
index = 0;
index = 1;
index = 1;
index = 1;
index = 1;
index = 2;
index = 2;
index = 2;
index = 2;
index = 3;
index = 3;
index = 3;
index = 3;
index = 4;
index = 4;
index = 4;
index = 4;
index = 5;
index = 5;
index = 5;
index = 5;
index = 6;
index = 6;
index = 6;
index = 6;
Animal* a = bird;
a->move()
sw
) im
fl y( swim()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = bird;
a->move()
Speculate
sw
() swim() im
fly ()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = bird;
a->move()
sw
) im
fl y( swim()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = bird;
a->move()
Execute sw
) im
fl y( swim()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = bird;
a->move()
sw
) im
fl y( fly()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = bird;
a->move()
Speculate
sw
) im
fl y( fly()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = bird;
a->move()
sw
) im
fl y( fly()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = fish;
a->move()
sw
) im
fl y( fly()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = fish;
a->move()
Speculate
sw
) im
fl y( fly()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = fish;
a->move()
sw
) im
fl y( fly()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = fish;
a->move()
sw Execute
() fly() i m
fly ()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 2) www.tugraz.at
Animal* a = fish;
a->move()
sw
) im
fl y( swim()
()
Prediction
LUT[data[index] * 4096] 0
25 Daniel Gruss — Graz University of Technology
Spectre (variant 5) www.tugraz.at
• “SpectreRSB”
• Similar to Spectre variant 2:
• Redirect an indirect branch (a return in this case)
• Fill buffer with “wrong” values
channel 0
channel 1
channel 0
front of DIMM:
rank 0
channel 1
channel 0
front of DIMM:
rank 0
chip
channel 1
bank 0
chip
row 0
row 1
row 2
...
row 32767
row buffer
bank 0
chip
row 0
row 1
row 2
...
row 32767 64k cells
1 capacitor,
row buffer
1 transitor each
DRAM bank
• Cells leak → repetitive refresh
11111111111111
necessary
11111111111111
11111111111111
• Maximum interval between
11111111111111 refreshes to guarantee data
... integrity
11111111111111
• Cells leak faster upon
proximate accesses →
row buffer
Rowhammer
DRAM bank
• Cells leak → repetitive refresh
11111111111111
necessary
activate
11111111111111
11111111111111
• Maximum interval between
11111111111111 refreshes to guarantee data
... copy integrity
11111111111111
• Cells leak faster upon
proximate accesses →
row buffer
Rowhammer
DRAM bank
• Cells leak → repetitive refresh
11111111111111
necessary
11111111111111
11111111111111
• Maximum interval between
activate
11111111111111 refreshes to guarantee data
... integrity
11111111111111 copy
• Cells leak faster upon
proximate accesses →
row buffer
Rowhammer
DRAM bank
• Cells leak → repetitive refresh
11111111111111
necessary
activate
11111111111111
11111111111111
• Maximum interval between
11111111111111 refreshes to guarantee data
... copy integrity
11111111111111
• Cells leak faster upon
proximate accesses →
row buffer
Rowhammer
DRAM bank
• Cells leak → repetitive refresh
11111111111111
necessary
11111111111111
11111111111111
• Maximum interval between
activate
11111111111111 refreshes to guarantee data
... integrity
11111111111111 copy
• Cells leak faster upon
proximate accesses →
row buffer
Rowhammer
DRAM bank
• Cells leak → repetitive refresh
11111111111111 bit flips in row 2! necessary
11111111111111
10111110101111
• Maximum interval between
11111111111111 refreshes to guarantee data
... integrity
11111111111111
• Cells leak faster upon
proximate accesses →
row buffer
Rowhammer
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
activate
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
11111111111111
11111111111111
11111111111111
activate
11111111111111
11111111111111
11111111111111
11111111111111
11111111111111
DRAM bank
JE HLT
0 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0
JE XORB
0 1 1 1 0 1 0 0 0 0 1 1 0 1 0 0
JE PUSHQ
0 1 1 1 0 1 0 0 0 1 0 1 0 1 0 0
JE <prefix>
0 1 1 1 0 1 0 0 0 1 1 0 0 1 0 0
JE JL
0 1 1 1 0 1 0 0 0 1 1 1 1 1 0 0
JE JO
0 1 1 1 0 1 0 0 0 1 1 1 0 0 0 0
JE JBE
0 1 1 1 0 1 0 0 0 1 1 1 0 1 1 0
JE JNE
0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1
(1) Start
B
X
X
B
• Instruction-set extension
• Integrity and confidentiality of code and data in untrusted
environments
• Run with user privileges and restricted, e.g., no system calls
• Run programs in enclaves using protected areas of memory
n er
s
nter
Patt
t
imit
Cou
prin
cess
sis
Prox
foot
ance
naly
y Ac
ic A
ory
orm
sica
or
Mem
Mem
Stat
Perf
Phy
Defense Class
Bypass
Intel SGX
One-location hammering
Opcode flipping
Memory waylaying
Defense class defeated
A unique chance to
• rethink processor design
A unique chance to
• rethink processor design
• many problems to solve around microarchitectural attacks
A unique chance to
• rethink processor design
• many problems to solve around microarchitectural attacks
• dedicate more time into identifying problems and not solely in
mitigating known problems
Daniel Gruss
September 19, 2018
Graz University of Technology