Process isolation, VMs and side channel Deian Stefan Slides - - PowerPoint PPT Presentation

process isolation vms and side channel
SMART_READER_LITE
LIVE PREVIEW

Process isolation, VMs and side channel Deian Stefan Slides - - PowerPoint PPT Presentation

CSE 127: Computer Security Process isolation, VMs and side channel Deian Stefan Slides adopted from Stefan Savage Process Isolation Process boundary is a trust boundary Any inter-process interface is part of the attack surface How


slide-1
SLIDE 1

Deian Stefan

Slides adopted from Stefan Savage

CSE 127: Computer Security

Process isolation, VMs and side channel

slide-2
SLIDE 2

Process Isolation

  • Process boundary is a trust boundary

➤ Any inter-process interface is part of the attack surface

  • How are individual processes isolated from each
  • ther?

➤ Each process gets its own virtual address space,

managed by the operating system

slide-3
SLIDE 3

Process Isolation

  • Process boundary is a trust boundary

➤ Any inter-process interface is part of the attack surface

  • How are individual processes isolated from each
  • ther?

➤ Each process gets its own virtual address space,

managed by the operating system

slide-4
SLIDE 4

Virtual Memory

  • Memory addresses used by

processes are virtual addresses

  • Who maps VAs to PAs?

➤ The operating system + MMU

https://en.wikipedia.org/wiki/Virtual_memory#/media/File:Virtual_memory.svg

slide-5
SLIDE 5

How do we get isolation?

Virtualized view of memory with limited visibility/ access to the underlying memory space

slide-6
SLIDE 6

How do we translate VAs?

  • Using 64-bit ARM architecture as an example…
  • How to practically map arbitrary 64bit

addresses?

➤ 64 bits * 264 (128 exabytes) to store any possible

mapping

slide-7
SLIDE 7

Address Translation

  • Page: basic unit of translation

➤ Usually 4KB

  • How many page mappings?

➤ 52 bits * 252 (208 petabytes)

… … … … …

00…00 FF…FF

slide-8
SLIDE 8

Address Translation

  • Page: basic unit of translation

➤ Usually 4KB

  • How many page mappings?

➤ 52 bits * 252 (208 petabytes)

… … … … …

00…00 FF…FF

slide-9
SLIDE 9

So what do we actually do?

Multi-level Page Tables

➤ Sparse tree of page mappings ➤ Use VA as path through tree ➤ Leaf nodes store PAs ➤ Where is the root kept?

… … … …

00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF 00 01 FF

00…00 FF…FF

slide-10
SLIDE 10

What are the nodes of the trees?

  • Page tables!

➤ Data structures used to store address mapping

  • Each table (node) is:

➤ Array of translation descriptors ➤ What’s the size of a page table?

slide-11
SLIDE 11

How do we use these tables?

  • Organized into a tree of descriptors

➤ Iteratively resolve n bits of address at a time ➤ Each descriptor is either

➤ Page descriptor (leaf node)

slide-12
SLIDE 12

How do we use these tables?

  • Organized into a tree of descriptors

➤ Iteratively resolve n bits of address at a time ➤ Each descriptor is either

➤ Page descriptor (leaf node) ➤ Table descriptor (internal node)

slide-13
SLIDE 13

Page table walk

… … … … … … …

Translation Table Base Register Invalid Descriptor Table Descriptor

address of next-level table

Page Descriptor

address of page

11..0 63..48

47 11

4KB 512 (29) entries 64 bits

slide-14
SLIDE 14

Page table walk

… … …

Level 0

9

… … … …

Translation Table Base Register Invalid Descriptor Table Descriptor

address of next-level table

Page Descriptor

address of page

11..0 63..48 47..39

47 11

4KB 512 (29) entries 64 bits

slide-15
SLIDE 15

Page table walk

Level 1 Level 0

9 9

Invalid Descriptor Table Descriptor

address of next-level table

Page Descriptor

address of page

11..0 63..48 38..30 47..39

47 11

4KB 512 (29) entries 64 bits

… … … … … … …

Translation Table Base Register

slide-16
SLIDE 16

Page table walk

Level 1 Level 0

9 9

Invalid Descriptor Table Descriptor

address of next-level table

Page Descriptor

address of page

11..0 63..48 38..30 47..39

47 11

4KB 512 (29) entries 64 bits

… … … … … … …

Translation Table Base Register

Level 2

9

29..21

slide-17
SLIDE 17

Page table walk

Level 1 Level 0

9 9

Invalid Descriptor Table Descriptor

address of next-level table

Page Descriptor

address of page

11..0 63..48 38..30 47..39

47 11

4KB 512 (29) entries 64 bits

… … … … … … …

Translation Table Base Register

Level 2

9

29..21

Level 3

9

20..12

slide-18
SLIDE 18

When do we do translation?

  • Every memory access a process performs goes

through address translation

➤ Load, store, instruction fetch ➤ Why is this necessary?

slide-19
SLIDE 19

When do we do translation?

  • Every memory access a process performs goes

through address translation

➤ Load, store, instruction fetch ➤ Why is this necessary?

  • Who does the translation?
slide-20
SLIDE 20

When do we do translation?

  • Every memory access a process performs goes

through address translation

➤ Load, store, instruction fetch ➤ Why is this necessary?

  • Who does the translation?

➤ MMU

slide-21
SLIDE 21

When do we do translation?

  • Every memory access a process performs goes

through address translation

➤ Load, store, instruction fetch ➤ Why is this necessary?

  • Who does the translation?

➤ MMU

slide-22
SLIDE 22

Translation Lookaside Buffer (TLB)

  • Small cache of recently translated addresses

➤ Before translating a referenced address, the

processor checks the TLB

  • What does the TLB give us?

➤ Physical page corresponding to virtual page


(or that page isn’t present)

➤ If page mapping allows the mode of access 


(access control)

slide-23
SLIDE 23

Translation Lookaside Buffer (TLB)

  • Small cache of recently translated addresses

➤ Before translating a referenced address, the

processor checks the TLB

  • What does the TLB give us?

➤ Physical page corresponding to virtual page


(or that page isn’t present)

➤ If page mapping allows the mode of access 


(access control)

slide-24
SLIDE 24

Access Control

  • Not everything within a processes’ virtual

address space is equally accessible

  • Page descriptors contain additional access

control information

➤ Read, Write, eXecute permissions ➤ Who sets these bits?

slide-25
SLIDE 25
  • Each process gets its own tree

➤ When you context switch: need to change root ➤ What do you do about TLB?

➤ Most often you flush ➤ Don’t need to flush if HW has process-context

identifiers (PCIDs)

How do we get process isolation?

slide-26
SLIDE 26
  • Each process gets its own tree

➤ When you context switch: need to change root ➤ What do you do about TLB?

➤ Most often you flush ➤ Don’t need to flush if HW has process-context

identifiers (PCIDs)

How do we get process isolation?

slide-27
SLIDE 27

Beyond process isolation

  • Kernel’s virtual memory space is mapped

into every process, but made inaccessible in usermode

➤ Why?

  • What happens on sys call?

➤ Translation Table Base Register updated

  • Do all processes share kernel?

process kernel

low address high address

slide-28
SLIDE 28

Kernel security

  • Threat model:

➤ Confidentiality and integrity of kernel memory and

control flow must be protected from compromise by usermode processes

➤ All usermode processes are untrusted and

potentially malicious

  • Operating model:

➤ Usermode processes make frequent calls into the

kernel, with data passing back and forth

slide-29
SLIDE 29

Meltdown broke this, so we have:

https://en.wikipedia.org/wiki/Kernel_page-table_isolation#/media/File:Kernel_page-table_isolation.svg

slide-30
SLIDE 30

Beyond process isolation: VMs

  • VM: the hardware running the OS is virtualized

➤ Each OS is oblivious to this happening (mostly) ➤ Hypervisor implements VM environment and

provides isolation between VMs

➤ Are processes within guest OS still isolated?

slide-31
SLIDE 31

How does address translation work?

  • Multiple stages of address translation to support

virtualization

➤ Hardware support for this (extended/nestate page

tables)
 
 
 
 
 
 


Virtual Address Intermediate Physical Address Physical Address Virtual Address Physical Address 1 1 2

slide-32
SLIDE 32

VM security

  • Details vary a lot between processor

architectures and operating system kernels

➤ Even within an architectural family, details may vary

a lot between specific processors

➤ Even within an operating system, details may vary a

lot between specific kernel versions

slide-33
SLIDE 33

How can we break isolation?

slide-34
SLIDE 34

Cache side channels

slide-35
SLIDE 35

Cache

  • Main memory is huge… but slow
  • Processors try to “cache” recently used memory

in faster, but smaller capacity, memory cells closer to the actual processing core

slide-36
SLIDE 36

Cache hierarchy

  • Caches are such a great idea,

let’s have caches for caches!

  • The close to the core, the:

➤ Faster ➤ Smaller

https://en.wikipedia.org/wiki/Cache_hierarchy

slide-37
SLIDE 37

How is the cache organized?

  • Cache line: unit of granularity

➤ E.g., 64 bytes

  • Cache lines grouped into sets

➤ Each memory address is mapped


to a set of cache lines

  • What happens when we have collisions?

➤ Evict!

https://en.wikipedia.org/wiki/CPU_cache

slide-38
SLIDE 38

How is the cache organized?

  • Cache line: unit of granularity

➤ E.g., 64 bytes

  • Cache lines grouped into sets

➤ Each memory address is mapped


to a set of cache lines

  • What happens when we have collisions?

➤ Evict!

https://en.wikipedia.org/wiki/CPU_cache

slide-39
SLIDE 39

Cache side channel attacks

  • Cache is a shared system resource

➤ Not isolated by process, VM, or privilege level ➤ “Just a performance optimization”

  • Can we abuse this shared resource to learn

information about another process, VM, etc.?

slide-40
SLIDE 40
  • Attacker and victim are isolated (e.g., processes)

but on the same physical system

  • Attacker is able to invoke (directly or indirectly)

functionality exposed by the victim

➤ What’s an example of this?

  • Attacker should not be able to infer anything

about the contents of victim memory

Thread model

slide-41
SLIDE 41

What is a side channel?

  • Many algorithms (e.g., crypto) have memory

access patterns that are dependent on sensitive memory contents

➤ If attacker can observe access patterns: learn data

slide-42
SLIDE 42

How do we observe patterns?

  • Approach 1

➤ Arranges to put the cache into a known state ➤ Lets victim run ➤ Checks to see what changed: what addresses have

appeared or disappeared from cache

  • How do we know if something in cache changed?

➤ Time access to it

slide-43
SLIDE 43

How do we observe patterns?

  • Approach 1

➤ Arranges to put the cache into a known state ➤ Lets victim run ➤ Checks to see what changed: what addresses have

appeared or disappeared from cache

  • How do we know if something in cache changed?

➤ Time access to it

slide-44
SLIDE 44

How do we observe patterns?

  • Approach 2

➤ Times normal victim operation (baseline) ➤ Makes controlled changes to cache contents:

evicting or fetching specific addresses

➤ Times victim operation again

slide-45
SLIDE 45

Evict & Time

  • Run the victim code several times and time it
  • Evict (portions of) the cache

➤ How?

  • Run the victim code again and time it
  • If it is slower than before, cache lines evicted by

the attacker must’ve been used by the victim

➤ We now know something about the addresses

accessed by victim code

slide-46
SLIDE 46

Prime & Probe

  • Prime the cache

➤ Access many memory locations so that previous

cache contents are replaced

  • Let victim code run
  • Time access to different memory locations,

slower means evicted by victim

➤ We now know something about the addresses

accessed by victim code

slide-47
SLIDE 47

Quite a few other approaches

  • Evict and Time (shared memory)
  • Prime and Abort (TSX)
slide-48
SLIDE 48

Flush & Reload

  • Flush the cache
  • Let victim code run
  • Time access to different memory locations,

faster means used by victim

➤ We now know something about the addresses

accessed by victim code

(Only for shared memory)

slide-49
SLIDE 49

How practical are these?

  • “Our robust and error-free channel even allows

us to build an SSH connection between two virtual machines, where all existing covert channels fail.”

slide-50
SLIDE 50

How practical are these?

  • “Our robust and error-free channel even allows

us to build an SSH connection between two virtual machines, where all existing covert channels fail.”

➤ Hello from the Other Side: SSH over Robust Cache

Covert Channels in the Cloud

➤ by Clementine Maurice, Manuel Weber, Michael

Schwarz, Lukas Giner, Daniel Gruss, Carlo Alberto Boano, Kay Romer, Stefan Mangard