Theory and Practice of Finding Eviction Sets Pepe Vila Boris Kpf - - PowerPoint PPT Presentation

theory and practice of finding eviction sets
SMART_READER_LITE
LIVE PREVIEW

Theory and Practice of Finding Eviction Sets Pepe Vila Boris Kpf - - PowerPoint PPT Presentation

Theory and Practice of Finding Eviction Sets Pepe Vila Boris Kpf Jos F. Morales IMDEA Software Institute Microsoft Research IMDEA Software Institute vwzq.net @cgvwzq github.com/cgvwzq Eviction Sets CACHE Find addresses that collide


slide-1
SLIDE 1

Theory and Practice of Finding Eviction Sets

Pepe Vila Boris Köpf José F. Morales IMDEA Software Institute Microsoft Research IMDEA Software Institute

vwzq.net @cgvwzq github.com/cgvwzq

slide-2
SLIDE 2

Eviction Sets

CACHE

SLICE 0 sets

associativity

SLICE 1 sets

Find addresses that collide in cache: i.e. addresses mapped into the same cache set

associativity

slide-3
SLIDE 3

Eviction Sets

CACHE

SLICE 0 sets

associativity

SLICE 1 sets

Find addresses that collide in cache: i.e. addresses mapped into the same cache set

associativity

slide-4
SLIDE 4

Eviction Sets

CACHE

SLICE 0 sets

associativity

SLICE 1 sets

Find addresses that collide in cache: i.e. addresses mapped into the same cache set

associativity

slide-5
SLIDE 5

Eviction Sets

CACHE

SLICE 0 sets

associativity

SLICE 1 sets

Find addresses that collide in cache: i.e. addresses mapped into the same cache set

associativity

Find associativity many colliding addresses: i.e. an eviction set

slide-6
SLIDE 6

Attacks

Efficient attacks require small eviction sets

slide-7
SLIDE 7

Attacks

Prime+Probe

Efficient attacks require small eviction sets

slide-8
SLIDE 8

Attacks

Prime+Probe Rowhammer

Efficient attacks require small eviction sets

slide-9
SLIDE 9

Attacks

Prime+Probe Rowhammer Spectre

Efficient attacks require small eviction sets

slide-10
SLIDE 10

Problem

PHYSICAL MEMORY CACHE

SLICE 0 sets SLICE 1 sets

associativity associativity

Potentially unknown mapping from physical address to cache set

slide-11
SLIDE 11

Problem

MMU

text heap stack

low high

USER PROCESS PHYSICAL MEMORY CACHE

SLICE 0 sets SLICE 1 sets

Unknown translation from virtual to physical addresses

associativity associativity

slide-12
SLIDE 12

Problem

<script> var foo = new Uint32Array(N); foo[12]; ... </script>

text heap stack

low high

USER PROCESS MMU PHYSICAL MEMORY CACHE

SLICE 0 sets SLICE 1 sets

In some scenarios, even unknown virtual address

associativity associativity

slide-13
SLIDE 13

Problem

<script> var foo = new Uint32Array(N); foo[12]; ... </script>

text heap stack

low high

USER PROCESS MMU PHYSICAL MEMORY CACHE

SLICE 0 sets SLICE 1 sets

Find associativity many elements (e.g. JS array indices) that collide in cache.

associativity associativity

slide-14
SLIDE 14

Contributions

Systematic study of the problem of finding eviction sets

slide-15
SLIDE 15

Contributions

Find eviction sets in O(n) compared to previous O(n2) Systematic study of the problem of finding eviction sets

slide-16
SLIDE 16

Contributions

Systematic study of the problem of finding eviction sets Find eviction sets in O(n) compared to previous O(n2) Reliability and performance evaluation

  • f algorithms in real hardware
slide-17
SLIDE 17

Find a large eviction set for an address V:

  • Pick “enough” addresses at random
  • Timing test:

Finding minimal eviction sets 1

slide-18
SLIDE 18

Find a large eviction set for an address V:

  • Pick “enough” addresses at random
  • Timing test:

Finding minimal eviction sets

Reduce initial large eviction set into its minimal core

2 1

slide-19
SLIDE 19

Find a large eviction set for an address V:

  • Pick “enough” addresses at random
  • Timing test:

Finding minimal eviction sets

Reduce initial large eviction set into its minimal core

2 1

slide-20
SLIDE 20

Baseline algorithm

N S : Start with large enough eviction set S of size N

slide-21
SLIDE 21

Baseline algorithm

N’ S : Pick candidate element C, and Test if remaining set TEST(S\{C}) is still an eviction set

slide-22
SLIDE 22

Baseline algorithm

S : If TEST(S\{C}) = True, discard C N’

slide-23
SLIDE 23

Baseline algorithm

N’ S : and continue with N’=N-1

slide-24
SLIDE 24

Baseline algorithm

N’ S : We repeat this process several times

slide-25
SLIDE 25

Baseline algorithm

N’ S : We repeat this process several times

slide-26
SLIDE 26

Baseline algorithm

N’ S : We repeat this process several times

slide-27
SLIDE 27

Baseline algorithm

N’ S : We repeat this process several times

slide-28
SLIDE 28

Baseline algorithm

N’ S : Until we find an element C such that when removed the remaining set stops being an eviction set: TEST(S\{C}) = False

slide-29
SLIDE 29

Baseline algorithm

N’ S : We learn that C is part of the minimal core

slide-30
SLIDE 30

Baseline algorithm

N’ S : We keep track of it, and insert it again in S

slide-31
SLIDE 31

Baseline algorithm

N’ S : We repeat this process several times

slide-32
SLIDE 32

Baseline algorithm

N’ S : We repeat this process several times

slide-33
SLIDE 33

Baseline algorithm

N’ S : We repeat this process several times

slide-34
SLIDE 34

Baseline algorithm

N’ S : We repeat this process several times

slide-35
SLIDE 35

Baseline algorithm

N’ S : We repeat this process several times

slide-36
SLIDE 36

Baseline algorithm

N’ S : We repeat this process several times

slide-37
SLIDE 37

Baseline algorithm

N’ S : We repeat this process several times

slide-38
SLIDE 38

Baseline algorithm

N’ S : We repeat this process several times

slide-39
SLIDE 39

Baseline algorithm

N’ S : We repeat this process several times

slide-40
SLIDE 40

Baseline algorithm

N’ S : We repeat this process several times

slide-41
SLIDE 41

Baseline algorithm

N’ S : Until we have identified ASSOCIATIVITY many elements representing the eviction set’s core! ASSOCIATIVITY

slide-42
SLIDE 42

Baseline algorithm

S :

O(N2) memory accesses

ASSOCIATIVITY N’

slide-43
SLIDE 43

Threshold Group Testing

Group testing problem by Robert Dorfman (1943)

Blood samples (10 individual tests)

slide-44
SLIDE 44

Threshold Group Testing

Group testing problem by Robert Dorfman (1943)

Blood samples (4 group tests + 3 individual tests )

slide-45
SLIDE 45

Threshold Group Testing

Group testing problem by Robert Dorfman (1943) Generalization by Peter Damaschke (2006):

  • Positive test only if at least “u” defectives
  • Negative test only if at most “l” defectives
  • Random otherwise

Blood samples (4 group tests + 3 individual tests )

slide-46
SLIDE 46

Blood samples (4 group tests + 3 individual tests )

Threshold Group Testing

Group testing problem by Robert Dorfman (1943) Generalization by Peter Damaschke (2006):

  • Positive test if at least “u” defectives
  • Negative test if at most “l” defectives
  • Random answer otherwise

Observation: Our test is a threshold group test!

slide-47
SLIDE 47

Group-testing algorithm

N S : Start with large enough eviction set S of size N

slide-48
SLIDE 48

Group-testing algorithm

N S : Split S in ASSOCIATIVITY+1 subsets

slide-49
SLIDE 49

Group-testing algorithm

N S : In the worst case, there exists a union of ASSOCIATIVITY subsets being an eviction set

slide-50
SLIDE 50

Group-testing algorithm

N S : We can discard N/(ASSOCIATIVITY+1) elements per iteration

slide-51
SLIDE 51

Group-testing algorithm

N’ S : We repeat this process until we have ASSOCIATIVITY many elements

slide-52
SLIDE 52

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-53
SLIDE 53

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-54
SLIDE 54

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-55
SLIDE 55

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-56
SLIDE 56

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-57
SLIDE 57

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-58
SLIDE 58

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-59
SLIDE 59

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-60
SLIDE 60

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-61
SLIDE 61

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-62
SLIDE 62

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-63
SLIDE 63

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-64
SLIDE 64

Group-testing algorithm

We repeat this process until we have ASSOCIATIVITY many elements N’ S :

slide-65
SLIDE 65

Group-testing algorithm

We find our minimal eviction set! ASSOCIATIVITY S :

slide-66
SLIDE 66

Group-testing algorithm

ASSOCIATIVITY S :

O(N) mem accesses

slide-67
SLIDE 67

Tool (C/x86): https://github.com/cgvwzq/evsets O(n) vs. O(n2) advantage shows up in practice! Finding minimal eviction sets is practical without knowledge on any bits

  • f the set index!

Y-right (lines): Average running time for eviction set reduction Y-left (columns): Cost of finding an initial eviction set of certain size X: Eviction set size in number of addresses Experiments on Skylake i5-6500 with 6MB cache (8192 sets x 12 assoc)

timeout

Performance Evaluation

slide-68
SLIDE 68

Robustness Evaluation

Modern replacement policies break our test assumption and introduce errors.

X: Cache set offset (each points aggregates all slices) Y: Average success rate for Green: reduction rate w/o error correcting mechanisms. Yellow: Test rate reliability Experiments on Skylake i5-6500 with 6MB cache (8192 sets x 12 assoc)

slide-69
SLIDE 69

Live demo (Bonus Material!)

Find minimal eviction sets on Chrome with JS and Wasm

Demo running on Chrome 74.0.3729.75 with V8 7.4 - CPU i7-8550U

slide-70
SLIDE 70

Conclusions

Finding minimal eviction sets is a threshold group-testing problem: new insight for research on principled countermeasures Novel linear-time algorithm makes attacks faster and enables them in scenarios previously considered impractical

slide-71
SLIDE 71

Thanks for your attention

Questions?

slide-72
SLIDE 72

Noise on difference machines and cache sets

slide-73
SLIDE 73

run.sh: google-chrome-beta --user-data-dir=/tmp/tmp.u9lo18kaTh

  • -js-flags='--allow-natives-syntax --experimental-wasm-bigint'

http://localhost:8000/ | ./verify_addr.sh

  • -allow-natives-syntax: used for printing found indices to stdout
  • -experimental-wasm-bigint: only for convenience, will have default support soon
  • verify_addr.sh:
  • find chrome’s PID
  • use pmap to find base virtual address for JS buffer
  • read JS indices and add them to virtual address base
  • execute ./virt_to_phys to translate virtual to physical addresses using /proc/pid/pagemap
  • extract slice and cache index set from physical address (uses Intel’s reverse engineered hash function)

Demo verification scripts

slide-74
SLIDE 74

0 55 push rbp 1 4889e5 movq rbp,rsp 4 6a0a push 0xa 6 56 push rsi 7 4883ec10 subq rsp,0x10 b 488b9ea7000000 movq rbx,[rsi+0xa7] 12 6666660f1f840000000000 nop 1d 0f1f00 nop 20 488b96c7000000 movq rdx,[rsi+0xc7] 27 483922 cmpq [rdx],rsp 2a 0f8340000000 jnc <+0x70> 30 8bc0 movl rax,rax 32 49ba0000000001000000 movq r10,0x100000000 3c 4c3bd0 cmpq r10,rax 3f 7320 jnc <+0x61> ... 61 488b0403 movq rax,[rbx+rax*1] 65 4883f800 cmpq rax,0x0 69 75b5 jnz <+0x20> 6b 488be5 movq rsp,rbp 6e 5d pop rbp 6f c3 retl

TurboFan x86_64 output

(func $x (param $ptr i64) (loop $iter (set_local $ptr (i64.load (i32.wrap/i64 (get_local $ptr)))) (br_if $iter (i32.eqz (i64.eqz (get_local $ptr))))) )

traverse.wat sign check stack guard epilogue prologue

(on V8 v7.4.0)

Example of TEST() in Wasm