xxx - usenix.org€¦ · sud's approach sud uml handles calls to kernel rt proxy driver and...

95
XXX

Upload: others

Post on 18-Oct-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

XXX

Page 2: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Tolerating Malicious Driversin Linux

Silas Boyd-Wickizer and Nickolai Zeldovich

Page 3: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

How could a device driver be malicious?

Today's device drivers are highly privileged

Write kernel memory, allocate memory, ...

Drivers are complex; developers write buggy code

Result: Attackers exploit vulnerabilities

Page 4: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

How could a device driver be malicious?

Today's device drivers are highly privileged

Write kernel memory, allocate memory, ...

Drivers are complex; developers write buggy code

Result: Attackers exploit vulnerabilities

Page 5: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

How could a device driver be malicious?

Today's device drivers are highly privileged

Write kernel memory, allocate memory, ...

Drivers are complex; developers write buggy code

Result: Attackers exploit vulnerabilities

Page 6: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Current approach

User-space drivers in μkernels (Minix, L4, ...)

Write device driver in new language (Termite)

Handle common faults (Nooks, microdrivers, ...)

Page 7: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Secure, efficient, & unmodified drivers on Linux

Goal

Page 8: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Previous user-space drivers

Kernel

User

Kernel core

Networkstack

Hardware

Ethernetdriver

User User

Application

μkernel

Page 9: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Previous user-space drivers

Kernel

User

Kernel core

Networkstack

Hardware

Ethernetdriver

User User

Application

μkernelConfine driver in a process

Page 10: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Previous user-space drivers

Kernel

User

Kernel core

Networkstack

Hardware

Ethernetdriver

User User

Application

μkernelConfine driver in a process

General purpose syscall API to

configure device

Page 11: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Previous user-space drivers

Kernel

User

Kernel core

Networkstack

Hardware

Ethernetdriver

User User

Application

μkernelConfine driver in a process

General purpose syscall API to

configure device

Confine device with IO virtualization HW.

Page 12: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Previous user-space drivers

Kernel

User

Kernel core

Networkstack

Hardware

Ethernetdriver

User User

Application

μkernelConfine driver in a process

General purpose syscall API to

configure device

IPC network driver APIE.g. tx_packet

Confine device with IO virtualization HW.

Page 13: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Current Linux driver architecture

Kernel

User

Ethernetdriver

Networkstack

Application

Hardware

netdeviceKernel RT

Page 14: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Current Linux driver architecture

Kernel

User

Ethernetdriver

Networkstack

Application

Hardware

netdeviceKernel RT

Kernel runtime (e.g. kmalloc)

Page 15: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Current Linux driver architecture

Kernel

User

Ethernetdriver

Networkstack

Application

Hardware

netdeviceKernel RT

Kernel runtime (e.g. kmalloc)

Network driver API (e.g. tx_packet)

Page 16: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Linux user-space driver problem

Kernel RT and driver APIs won't work for untrusted drivers in a different AS

Kernel

UserEthernetdriver

Networkstack

Application

Hardware

netdevice

User

Kernel RT

Page 17: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD's approach

Kernel

UserEthernetdriver

Networkstack

Application

Hardware

netdevice

User

Kernel RT

Page 18: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD's approach

SUD UML handles calls to kernel RT

Kernel

UserEthernetdriver

Networkstack

Application

Hardware

netdevice

User

Kernel RT

SUD UML

Page 19: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD's approach

SUD UML handles calls to kernel RT

Proxy driver and SUD UML allow reuse of existing driver APIs

Kernel

UserEthernetdriver

Networkstack

Application

Hardware

netdevice

User

Kernel RT

SUD UML

Ethernetproxy driver

Page 20: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD's approach

SUD UML handles calls to kernel RT

Proxy driver and SUD UML allow reuse of existing driver APIs

Kernel

UserEthernetdriver

Networkstack

Application

Hardware

netdevice

User

Kernel RT

SUD UML

Ethernetproxy driver

Network driver API

Page 21: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD's approach

SUD UML handles calls to kernel RT

Proxy driver and SUD UML allow reuse of existing driver APIs

Kernel

UserEthernetdriver

Networkstack

Application

Hardware

netdevice

User

Kernel RT

SUD UML

Ethernetproxy driver

Network driver API

SUD RPC API

Page 22: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD's approach

SUD UML handles calls to kernel RT

Proxy driver and SUD UML allow reuse of existing driver APIs

Kernel

UserEthernetdriver

Networkstack

Application

Hardware

netdevice

User

Kernel RT

SUD UML

Ethernetproxy driver

Network driver API

SUD RPC API

Network driver API

Page 23: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD's results

Tolerate malicious device drivers

Proxy drivers small (~500 LOC)

One proxy driver per device class

Few kernel modifications (~50 LOC)

Unmodified drivers (6 test drivers)

High performance, low overhead

No need for new OS or language

Page 24: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Security challenge: prevent attacks

Problem: driver must perform privileged operations

Memory access, driver API, DMA, interrupts, …

Attacks from driver code:

Direct system attacks: memory corruption, ...

Driver API attacks: invalid return value, deadlock, ...

Attacks from device:

DMA to DRAM, peer-to-peer attacks, interrupt storms

Page 25: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Practical challenges

High performance, low overhead

Challenge: interact with hardware and kernel at high rate, kernel-user switch expensive

E.g. Ethernet driver ~100k times a second

Reuse existing drivers and kernel

Challenge: drivers assume fully-privileged kernel env.

Challenge: kernel driver API complex, non-uniform

Page 26: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD overview

Kernel

User

Proxy driver Kernel core

Application

Hardware

Driver

User

SUD UML

HW accessmodule

Page 27: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD overview

Kernel

User

Proxy driver Kernel core

Application

Hardware

Driver

User

SUD UML

HW accessmodule

Page 28: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Linux driver APIs

Linux defines a driver API for each device class

Driver and kernel functions and variables

Page 29: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example: wireless driver API

Linux defines a driver API for each device class

Driver and kernel functions and variablesstruct wireless_ops {

int (*tx)(struct sk_buff*);

int (*configure_filter)(int);

...

};

struct wireless_hw {

int conf;

int flags

....

};

Page 30: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example: wireless driver API

Linux defines a driver API for each device class

Driver and kernel functions and variables

Proxy drivers and SUD-UML convert API to RPCs

struct wireless_ops {

int (*tx)(struct sk_buff*);

int (*configure_filter)(int);

...

};

struct wireless_hw {

int conf;

int flags

....

};

Page 31: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example: wireless driver API

Linux defines a driver API for each device class

Driver and kernel functions and variables

Proxy drivers and SUD-UML convert API to RPCs

struct wireless_ops {

int (*tx)(struct sk_buff*);

int (*configure_filter)(int);

...

};

struct wireless_hw {

int conf;

int flags

....

};

Page 32: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example: wireless driver API

Linux defines a driver API for each device class

Driver and kernel functions and variables

Proxy drivers and SUD-UML convert API to RPCs

struct wireless_ops {

int (*tx)(struct sk_buff*);

int (*configure_filter)(int);

...

};

struct wireless_hw {

int conf;

int flags

....

};

Called in a non-preemptable context

Page 33: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example: wireless driver API

Linux defines a driver API for each device class

Driver and kernel functions and variables

Proxy drivers and SUD-UML convert API to RPCs

struct wireless_ops {

int (*tx)(struct sk_buff*);

int (*configure_filter)(int);

...

};

struct wireless_hw {

int conf;

int flags

....

};

Called in a non-preemptable context

Driver API variable

Page 34: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Wireless driver in SUD

Basic driver API → SUD RPC API→ driver API

Non-preemptable function: implement in proxy

Driver API variable: shadow variables

Page 35: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 1: transmit a packet

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Page 36: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 1: transmit a packet

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Socket write

Page 37: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 1: transmit a packet

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UMLwireless_ops.tx

Page 38: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 1: transmit a packet

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

TX packet RPC

Page 39: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 1: transmit a packet

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_ops.tx

Page 40: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 1: transmit a packet

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

DMA TX

Page 41: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 2: non-preemptable callback

Problem: unable to switch to user-space

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Page 42: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML Acquires a spin lock

Example 2: non-preemptable callback

Page 43: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UMLwireless_ops.configure_filter

Example 2: non-preemptable callback

Page 44: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Filter RPC

Example 2: non-preemptable callback

Page 45: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Example 2: non-preemptable callback

Page 46: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Solution: implement directly in proxy driver

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Example 2: non-preemptable callback

Page 47: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Solution: implement directly in proxy driver

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Register RX packet types

Example 2: non-preemptable callback

Page 48: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Solution: implement directly in proxy driver

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Example 2: non-preemptable callback

Acquires a spin lock

Page 49: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Solution: implement directly in proxy driver

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Example 2: non-preemptable callback

wireless_ops.configure_filter

Page 50: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: unable to switch to user-space

Solution: implement directly in proxy driver

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

Example 2: non-preemptable callback

Return RX packet types

Page 51: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Example 3: driver API variables

Problem: user-space can't access API variables

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

Page 52: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

Driver API variable

Example 3: driver API variables

Page 53: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

Writes to wireless_hw

Example 3: driver API variables

Page 54: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

Example 3: driver API variables

Page 55: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Solution: allocate a shadow copy and synchronize before and after RPCs

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

Example 3: driver API variables

Page 56: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Solution: allocate a shadow copy and synchronize before and after RPCs

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

wireless_hw

Shadow variable

Example 3: driver API variables

Page 57: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Solution: allocate a shadow copy and synchronize before and after RPCs

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

wireless_hw Writes to wireless_hw

Example 3: driver API variables

Page 58: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Solution: allocate a shadow copy and synchronize before and after RPCs

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

wireless_hw

Synchronize before sending RPC

Example 3: driver API variables

Page 59: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Solution: allocate a shadow copy and synchronize before and after RPCs

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

wireless_hw

Send RPC

Example 3: driver API variables

Page 60: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Problem: user-space can't access API variables

Solution: allocate a shadow copy and synchronize before and after RPCs

Kernel

User

Wirelessproxy driver

Wirelesscore

Webbrowser

Hardware

Wirelessdriver

User

SUD UML

wireless_hw

wireless_hw

Reads updates from shadow variable

Example 3: driver API variables

Page 61: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD overview

Kernel

User

Proxy driver Kernel core

Application

Hardware

Driver

User

SUD UML

HW accessmodule

Page 62: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD overview

Kernel

User

Proxy driver Kernel core

Application

Hardware

Driver

User

SUD UML

HW accessmodule

Page 63: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Attacks from hardware

CPU

PCI bus

DRAM

Memory interconnect

Page 64: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Attacks from hardware

CPU

PCI bus

DRAM

Memory interconnect

Driver configures the device to execute attacks

Page 65: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Attacks from hardware

CPU

PCI bus

DRAM

Memory interconnect

Driver configures the device to execute attacks

DMA to DRAM

Page 66: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Attacks from hardware

CPU

PCI bus

DRAM

Memory interconnect

Driver configures the device to execute attacks

DMA to DRAM

Peer-to-peer messages

Page 67: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Attacks from hardware

CPU

PCI bus

DRAM

Memory interconnect

Driver configures the device to execute attacks

DMA to DRAM

Peer-to-peer messages

Interrupt storms

Page 68: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Attacks from hardware

Driver configures the device to execute attacks

DMA to DRAM

Peer-to-peer messages

Interrupt storms

HW access module prevents attacks

Interposes on driver-device communication

Uses IO virtualization to provide direct device access

Page 69: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

IO virtualization hardware

CPU MSI

IOMMUPCI express

switch

DRAM

Memory interconnect

APIC interconnect

Page 70: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

IO virtualization hardware

CPU MSI

IOMMUPCI express

switch

DRAM

Memory interconnect

APIC interconnect

Use IOMMU to map DMA buffer pools

Prevents DMA to DRAM attacks

Page 71: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

IO virtualization hardware

CPU MSI

IOMMUPCI express

switch

DRAM

Memory interconnect

APIC interconnect

Use PCI ACS to prevent peer-to-peer messaging

Prevents peer-to-peer attacks

Page 72: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

IO virtualization hardware

CPU MSI

IOMMUPCI express

switch

DRAM

Memory interconnect

APIC interconnect

Use MSI to mask interrupts

Prevents interrupt storms

Page 73: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers in Linux

Kernel

Driver IRQ core

UserMSI

Page 74: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers in Linux

Kernel

Driver IRQ core

UserMSI

Page 75: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers in Linux

Driver called with IRQs disabled (non-preemptable)

Kernel

Driver IRQ core

UserMSI

Page 76: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers in Linux

Kernel calls driver interrupt handler

Driver clears interrupt flag

Kernel

Driver IRQ core

UserMSI

Page 77: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers with SUD

Kernel

HW accessmodule

IRQ core

UserMSI

Driver

SUD UML

Page 78: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers with SUD

Kernel calls HW access module interrupt handler

HW access module masks interrupt with MSI

Kernel

HW accessmodule

IRQ core

UserMSI

Driver

SUD UML

Page 79: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers with SUD

Kernel calls HW access module interrupt handler

HW access module masks interrupt with MSI

Kernel

HW accessmodule

IRQ core

UserMSI

Driver

SUD UML

Page 80: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers with SUD

Kernel calls HW access module interrupt handler

HW access module masks interrupt with MSI

Asynchronous RPC to driver

Kernel

HW accessmodule

IRQ core

UserMSI

Driver

SUD UML

Page 81: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers with SUD

Kernel calls HW access module interrupt handler

HW access module masks interrupt with MSI

Asynchronous RPC to driver

Driver clears interrupt

Kernel

HW accessmodule

IRQ core

UserMSI

Driver

SUD UML

Page 82: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Interrupt handlers with SUD

HW access module masks interrupt with MSI

Asynchronous RPC to driver

Driver clears interrupt

HW access module unmasks MSI

Kernel

HW accessmodule

IRQ core

UserMSI

Driver

SUD UML

Page 83: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD overview

Kernel

User

Proxy driver Kernel core

Application

Hardware

Driver

User

SUD UML

HW accessmodule

Page 84: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Prototype of SUD

Supports all Ethernet, wireless, USB, audio drivers

Tested: e1000e, ne2k-pci, iwlagn, snd_hda_intel, ehci_hcd, uhci_hcd, ...

Trusted code Lines of codePCI access module 2800Ethernet proxy driver 300Wireless proxy driver 600Audio proxy driver 550

Untrusted code Lines of codeUser-mode runtime 5000Drivers 5000 – 50,000 (each)

Page 85: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Trusted code Lines of codePCI access module 2800Ethernet proxy driver 300Wireless proxy driver 600Audio proxy driver 550

Untrusted code Lines of codeUser-mode runtime 5000Drivers 5000 – 50,000 (each)

Prototype of SUD

Supports all Ethernet, wireless, USB, audio drivers

Tested: e1000e, ne2k-pci, iwlagn, snd_hda_intel, ehci_hcd, uhci_hcd, ...

Page 86: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Trusted code Lines of codePCI access module 2800Ethernet proxy driver 300Wireless proxy driver 600Audio proxy driver 550

Untrusted code Lines of codeUser-mode runtime 5000Drivers 5000 – 50,000 (each)

Prototype of SUD

Supports all Ethernet, wireless, USB, audio drivers

Tested: e1000e, ne2k-pci, iwlagn, snd_hda_intel, ehci_hcd, uhci_hcd, ...

Page 87: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Performance

For most devices, does not matter

Printers, cameras, …

Stress-test: e1000e gigabit network card

Requires high throughput

Requires low latency

Many device driver interactions

Test machine: 1.4GHz dual core Thinkpad

Page 88: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Performance questions?

What performance does SUD get?

Network throughput, latency

How much does it cost?

CPU cycles

Page 89: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

SUD achieves same device performance

TCP UDP TX UDP RX UDP latency0

0.2

0.4

0.6

0.8

1

LinuxSud

Normalized throughput relative to Linux

TCP: streaming (950 Mbps in both cases)

UDP: one-byte-data packets

Thr

ough

put

rela

tive

to L

inux

Page 90: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

CPU cost is low

TCP UDP TX UDP RX UDP latency0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

LinuxSud

SUD overhead: user-kernel switch, TLB misses

Overheads not significant for many workloads(packets larger than min. packet size)

CP

U u

tiliz

atio

n

Page 91: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Future directions

Explore hierarchical untrusted device drivers

PCI bus → SATA controller → SATA disk → …

Explore giving apps direct hardware access

Safe HW access for network analyzer, X server, …

Performance analysis and optimizations

SUD specific device drivers, super pages, ...

Page 92: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Related work

Mircokernels (Minix, L4, ...)

Simple drivers, driver API designed for user-space

Nooks, microdrivers

Handles common bugs, many changes to kernel

Languages (e.g. Termite), source code analysis

Complimentary to user-space drivers

No need for new OS or language

Page 93: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Summary

Driver bugs lead to system crashes or exploits

SUD protects Linux from malicious drivers using proxy drivers and IO virtualization HW

Runs unmodified Linux device drivers

High performance, low overheads

Few modifications to Linux kernel

Page 94: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application
Page 95: XXX - usenix.org€¦ · SUD's approach SUD UML handles calls to kernel RT Proxy driver and SUD UML allow reuse of existing driver APIs Kernel Ethernet User driver Network stack Application

Security evaluation

Manually constructed potential attacks

Memory corruption, arbitrary upcall responses,not responding at all, arbitrary DMA, ...

Relied on security heavily during development

SUD caught all bugs in user-mode driver framework

No crashes / reboots required to develop drivers

Ideal, but not done: red-team evaluation?