RevNIC. Reverse Engineering of Binary Device Drivers. Vitaly Chipounov and George Candea School of Computer & Communica3on Sciences



Similar documents
Reverse Engineering of Binary Device Drivers with RevNIC

Full and Para Virtualization

Virtualization Technologies

Virtualization System Vulnerability Discovery Framework. Speaker: Qinghao Tang Title:360 Marvel Team Leader

Introduction to Virtual Machines

Chapter 14 Virtual Machines

Virtual machines and operating systems

Advanced Computer Networks. Network I/O Virtualization

Xen and the Art of. Virtualization. Ian Pratt

Virtualization. Types of Interfaces

Virtualization for Cloud Computing

Performance Evaluation of VMXNET3 Virtual Network Device VMware vsphere 4 build

Cloud9 Parallel Symbolic Execution for Automated Real-World Software Testing

Basics in Energy Information (& Communication) Systems Virtualization / Virtual Machines

USB to RS-422/485 Serial Adapter

Datacenter Operating Systems

Virtualization Technology. Zhiming Shen

Bridging the Gap between Software and Hardware Techniques for I/O Virtualization

Uses for Virtual Machines. Virtual Machines. There are several uses for virtual machines:

Assessing the Performance of Virtualization Technologies for NFV: a Preliminary Benchmarking

KVM: Kernel-based Virtualization Driver

Introduction to the NI Real-Time Hypervisor

Xenomai: integration and qualification of a real time operating system ARMadeus Systems

Dynamically Translating x86 to LLVM using QEMU

12. Introduction to Virtual Machines

COS 318: Operating Systems. Virtual Machine Monitors

VMware vsphere 5.0 Boot Camp

Virtualization. Pradipta De

Virtual Machine in Automation Projects

High-performance vnic framework for hypervisor-based NFV with userspace vswitch Yoshihiro Nakajima, Hitoshi Masutani, Hirokazu Takahashi NTT Labs.

VMware vsphere 5.1 Advanced Administration

Optimizing Network Virtualization in Xen

Evading Android Emulator

Hypervisors and Virtual Machines

x86 ISA Modifications to support Virtual Machines

Virtual Switching Without a Hypervisor for a More Secure Cloud

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Gigabit Ethernet Design

I/O virtualization. Jussi Hanhirova Aalto University, Helsinki, Finland Hanhirova CS/Aalto

Basics of Virtualisation

Chapter 5 Cloud Resource Virtualization

Hyper-V R2: What's New?

Outline. Outline. Why virtualization? Why not virtualize? Today s data center. Cloud computing. Virtual resource pool

Next Generation Operating Systems

Regional SEE-GRID-SCI Training for Site Administrators Institute of Physics Belgrade March 5-6, 2009

Date: December 2009 Version: 1.0. How Does Xen Work?

Enhancing Hypervisor and Cloud Solutions Using Embedded Linux Iisko Lappalainen MontaVista

Virtualised MikroTik

Architecture of the Kernel-based Virtual Machine (KVM)

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Virtual Machines. COMP 3361: Operating Systems I Winter

Windows Server 2008 R2 Hyper-V Live Migration

Virtualization in Linux KVM + QEMU

Automatic Logging of Operating System Effects to Guide Application-Level Architecture Simulation

Intel Virtualization Technology

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

Where IT perceptions are reality. Test Report. OCe14000 Performance. Featuring Emulex OCe14102 Network Adapters Emulex XE100 Offload Engine

VON/K: A Fast Virtual Overlay Network Embedded in KVM Hypervisor for High Performance Computing

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

EXPLORING LINUX KERNEL: THE EASY WAY!

Virtualization. Jukka K. Nurminen

Performance Profiling in a Virtualized Environment

Intel DPDK Boosts Server Appliance Performance White Paper

Performance Analysis of Large Receive Offload in a Xen Virtualized System

IxChariot Virtualization Performance Test Plan

High-performance vswitch of the user, by the user, for the user

IOS110. Virtualization 5/27/2014 1

Toward a practical HPC Cloud : Performance tuning of a virtualized HPC cluster

Networking Virtualization Using FPGAs

Performance Evaluation of Linux Bridge

The Plan Today... System Calls and API's Basics of OS design Virtual Machines

OPTIMIZE DMA CONFIGURATION IN ENCRYPTION USE CASE. Guillène Ribière, CEO, System Architect

Virtual Machines. Virtualization

The XenServer Product Family:

Wireshark in a Multi-Core Environment Using Hardware Acceleration Presenter: Pete Sanders, Napatech Inc. Sharkfest 2009 Stanford University

Comparative Study of Virtual Machine Software Packages with Real Operating System

KVM, OpenStack, and the Open Cloud

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

DPDK Summit 2014 DPDK in a Virtual World

Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software

Virtualization of Linux based computers: the Linux-VServer project

VMWARE VSPHERE 5.0 WITH ESXI AND VCENTER

Best Practises for LabVIEW FPGA Design Flow. uk.ni.com ireland.ni.com

Concurrent Direct Network Access for Virtual Machine Monitors

Virtualizing a Virtual Machine

Intel Virtualization Technology Overview Yu Ke

Networked I/O for Virtual Machines

Virtualization. Explain how today s virtualization movement is actually a reinvention

A Comparison of VMware and {Virtual Server}

Knut Omang Ifi/Oracle 19 Oct, 2015

OS Virtualization Frank Hofmann

Virtual Machines. Virtual Machines

Leveraging NIC Technology to Improve Network Performance in VMware vsphere

Beyond the Hypervisor

Virtualization Strategy with Oracle VM and Oracle Linux. Bjorn Naessens

Linux Driver Devices. Why, When, Which, How?

Programmable Networking with Open vswitch

Transcription:

RevNIC Reverse Engineering of Binary Device Drivers Vitaly Chipounov and George Candea School of Computer & Communica3on Sciences

Drivers: Hard to Write and Hard to Port Drivers are o@en closed source Por3ng from exis3ng drivers is difficult Devices rarely come with an interface specificadon Hard to write a driver from scratch SpecificaDons are o@en incomplete and buggy Buggy driver implementa3on

ExisDng SoluDons EmulaDng source OS (VMs, NDISwrapper...) Run 3me overhead, hard to maintain Making drivers from specificadons (Termite) Requires formal specifica3ons Manual trace analysis, decompiladon Tedious, imprecise

Windows Windows Linux KitOS μc/os II x86 PC Virtual Machines FPGA http://bplteensofwa.files.wordpress.com/2009/07/computer.jpg

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

High Coverage Driver Exerciser Hand cra@ed workload is not enough

int irq_handler(device_t *dev) { status = hw_read(status_reg); if (status == RX){ pkt_size = hw_read(rx_size_reg); if (pkt_size < 1514) { recv_packet(dev); else { drop_packet(dev); else if (status == TX) {...

int irq_handler(device_t *dev) { status = hw_read(status_reg); if (status == RX){ pkt_size = hw_read(rx_size_reg); if (pkt_size < 1514) { recv_packet(dev); else { drop_packet(dev); else if (status == TX) {... Boundary condidons Error recovery code

int irq_handler(device_t *dev) { status = hw_read(status_reg); if (status == RX){ pkt_size = hw_read(rx_size_reg); if (pkt_size < 1514) { recv_packet(dev); else { drop_packet(dev); else if (status == TX) {...

int irq_handler(device_t *dev) { status = hw_read(status_reg); if (status == RX){ pkt_size = hw_read(rx_size_reg); if (pkt_size < 1514) { recv_packet(dev); else { drop_packet(dev); else if (status == TX) {...

int irq_handler(device_t *dev) { status = hw_read(status_reg); if (status == RX){ pkt_size = hw_read(rx_size_reg); if (pkt_size < 1514) { recv_packet(dev); else { drop_packet(dev); else if (status == TX) {... status == TX status == RX F T...... drop packet pkt_size < 1514 receive packet

int irq_handler(device_t *dev) { status = hw_read(status_reg); if (status == RX){ pkt_size = hw_read(rx_size_reg); if (pkt_size < 1514) { recv_packet(dev); else { drop_packet(dev); else if (status == TX) {... status == TX status == RX F T...... drop packet pkt_size < 1514 receive packet High coverage automated driver exerciser

explorer.exe... advapi32.dll Applications and... libraries msvcrt.dll ntdll.dll user32.dll... Device Drivers Windows Kernel ndis.sys rtl8139.sys...

Exercising Windows NIC Drivers NICDRIVER.SYS IniDalize(...) QueryInformaDon(...)... SendPacket(...) HandleInterrupt(...) Unload(...)

Exercising Windows NIC Drivers NICDRIVER.SYS IniDalize(...) QueryInformaDon(...)... SendPacket(...) HandleInterrupt(...) Unload(...)

Exercising Windows NIC Drivers IniDalize(...)

Exercising Windows NIC Drivers IniDalize(...)

Exercising Windows NIC Drivers IniDalize(...)

IniDalize(...)

IniDalize(...) Send(..., Packet,...)

IniDalize(...) 001a706650e3... Send(..., Packet,...)

IniDalize(...) α β γ δ ε ϛ... Send(..., Packet,...)

α β γ δ ε ϛ... Send(..., Packet,...)

α β γ δ ε ϛ... Send(..., Packet,...) Interrupt

α β γ δ ε ϛ... Send(..., Packet,...) Interrupt HandleInterrupt(...)

(..., Packet,...) Interrupt dleinterrupt(...)

(..., Packet,...) Interrupt dleinterrupt(...) Unload(...)

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac,on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

Hardware InteracDon Traces Virtual Machine Guest OS Original Binary Driver Driver Exerciser ExecuDon tree Machine instrucdons Memory accesses Register values (Memory Mapped) I/O Trace Files

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac,on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template Traces C code SyntheDc Driver

ExecuDon Tree

ExecuDon Tree Sequences of basic blocks BB 1 BB 2 BB 3 BB 4 BB 5 BB 6 BB 7 Trace #1

ExecuDon Tree Sequences of basic blocks BB 1 BB 2 BB 3 BB 4 BB 5 BB 6 BB 7 BB 1 BB 2 BB 3 BB 4 BB 8 BB 9 BB 7 Trace #1 Trace #2

BB 1 BB 2 BB 3 BB 4 BB 5 BB 6 BB 7 BB 1 BB 2 BB 3 BB 4 BB 8 BB 9 BB 7 Trace #1 Trace #2

BB 1 BB 2 BB 3 BB 4 BB 5 BB 6 BB 7 BB 1 BB 2 BB 3 BB 4 BB 8 BB 9 BB 7 Trace #1 Trace #2

BB 1 BB 2 BB 3 BB 4 BB 1 BB 2 BB 3 BB 4 BB 1 BB 2 BB 3 BB 4 BB 5 BB 8 BB 6 BB 5 BB 8 BB 9 BB 7 BB 6 BB 9 BB 7 Trace #1 BB 7 Trace #2

CFG BB 1 BB 2 BB 3 BB 4 BB 1 BB 2 BB 3 BB 4 BB 1 BB 2 BB 3 BB 4 BB 5 BB 8 BB 6 BB 5 BB 8 BB 9 BB 7 BB 6 BB 9 BB 7 Trace #1 BB 7 Trace #2

CFG BB 1 BB 2 BB 3 BB 4 BB 5 BB 8 BB 6 BB 9 BB 7

CFG BB 1 BB 2 BB 3 BB 4 uint32_t function_0001(...) { BB1: BB2: BB3: BB4: BB 5 BB 6 BB 8 BB 9 BB5: BB6: BB8: BB9: BB 7 BB7:

BB 5 BB 6 CFG BB 1 BB 2 BB 3 BB 4 BB 7 BB 8 BB 9 uint32_t function_0001(uint32_t param1, uint32_t param2) { /*... */ BB1: goto BB2; BB2: v1 = read_port(param1); BB3: v2 = read_port(param2); BB4: if (v1 & 0x21) goto BB8; BB5: write_port(param2, 0x1234); BB6: goto BB7; BB8: write_port(param1, 0x4567); BB9: goto BB7; BB7:

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template Traces C code SyntheDc Driver

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer Traces C code NIC Driver Template C code driver SyntheDc Driver

Device Driver Structure Hardware facing funcdons Automa3cally synthesized by RevNIC OS facing funcdons Provided by the driver template

Hardware InteracDon Code Template Driver

Linux Network Driver Template Templates contain OSspecific boilerplate int pci_nic_init(...) { /* Allocate device resources */ i = pci_enable_device (pdev); if (i) {... ioaddr = pci_resource_start (pdev, 0); irq = pdev->irq; if (request_region (ioaddr, ADDR_RANGE, DRV_NAME) == NULL) {... /* --------------------------------- * Insert device detection code here * --------------------------------- */ /* Allocate private memory */ dev = alloc_netdev(...); if (!dev) {... /* Register entry points */...

Linux Network Driver Template Templates contain OSspecific boilerplate int pci_nic_init(...) { /* Allocate device resources */ i = pci_enable_device (pdev); if (i) {... ioaddr = pci_resource_start (pdev, 0); irq = pdev->irq; if (request_region (ioaddr, ADDR_RANGE, DRV_NAME) == NULL) {... /* --------------------------------- * Insert device detection code here * --------------------------------- */ /* Allocate private memory */ dev = alloc_netdev(...); if (!dev) {... /* Register entry points */...

int pci_nic_init(...) { /* Allocate device resources */ i = pci_enable_device (pdev); if (i) {... ioaddr = pci_resource_start (pdev, 0); irq = pdev->irq; if (request_region (ioaddr, ADDR_RANGE, DRV_NAME) == NULL) {... /* --------------------------------- * Insert device detection code here * --------------------------------- */ /* Allocate private memory */ dev = alloc_netdev(...); if (!dev) {... /* Register entry points */...

int pci_nic_init(...) { /* Allocate device resources */ i = pci_enable_device (pdev); if (i) {... ioaddr = pci_resource_start (pdev, 0); irq = pdev->irq; if (request_region (ioaddr, ADDR_RANGE, DRV_NAME) == NULL) {... /* --------------------------------- * Insert device detection code here * --------------------------------- */ Placeholders for hardware interacdon /* Allocate private memory */ dev = alloc_netdev(...); if (!dev) {... /* Register entry points */...

int pci_nic_init(...) { /* Allocate device resources */ i = pci_enable_device (pdev); if (i) {... ioaddr = pci_resource_start (pdev, 0); irq = pdev->irq; if (request_region (ioaddr, ADDR_RANGE, DRV_NAME) == NULL) {... /* --------------------------------- * Insert device detection code here * --------------------------------- */ if (hw_checkdevice(ioaddr) < 0) { v1 = read_port(ioaddr); if (!(v1 & 1)) { goto lbl0; write_port(ioaddr, 0); lbl0: write_port(ioaddr, 1); /* Allocate private memory */ dev = alloc_netdev(...); if (!dev) {... /* Register entry points */...

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver

RevNIC Virtual Machine Guest OS Original Binary Driver Driver Exerciser Hardware interac3on traces RevNIC Code Synthesizer NIC Driver Template SyntheDc Driver insmod revnic_driver.ko

ImplementaDon QEMU virtual machine 1 x86 to LLVM translator KLEE symbolic execudon engine 2 1 F. Bellard. QEMU, a Fast and Portable Dynamic Translator. In USENIX 2005. 2 C. Cadar et al. KLEE: Unassisted and automa3c genera3on of high coverage tests for complex systems programs. In OSDI 2008.

EvaluaDon RevNIC can port network drivers between different OS plaiorms different hardware architectures SyntheDc drivers have good performance

Reverse Engineered Drivers Driver Size 1 AMD PCNet Realtek RTL8139 SMSC 91C111 Realtek RTL8029 (NE2000) 35 KB 20 KB 19 KB 18 KB 1 80% of Linux 2.6.26 NIC drivers are smaller than 35KB

Target Plaiorms Windows Windows Linux KitOS μc/os II http://bplteensofwa.files.wordpress.com/2009/07/computer.jpg

Target Plaiorms Windows Windows Linux KitOS μc/os II x86 PC RTL8139 http://bplteensofwa.files.wordpress.com/2009/07/computer.jpg

Target Plaiorms Windows Windows Linux KitOS μc/os II x86 PC VMware QEMU RTL8139 PCnet, NE2000 http://bplteensofwa.files.wordpress.com/2009/07/computer.jpg

Target Plaiorms Windows Windows Linux KitOS μc/os II x86 PC RTL8139 VMware QEMU PCnet, NE2000 FPGA4U SMSC 91C111 http://bplteensofwa.files.wordpress.com/2009/07/computer.jpg

EffecDveness RevNIC reverse engineers all relevant funcdonality IniDalizaDon, sending, recepdon, shutdown, DMA, etc.

Performance Throughput (Mbps) 100 80 60 40 20 0 Windows KitOS Windows Windows Linux Original Windows Linux Windows Original 0 200 400 600 800 1000 1200 1400 UDP Packet Size (Bytes)

Performance Throughput (Mbps) 100 80 60 40 20 0 Windows KitOS Windows Windows Linux Original Windows Linux Windows Original 0 200 400 600 800 1000 1200 1400 UDP Packet Size (Bytes)

Performance Throughput (Mbps) 100 80 60 40 20 0 Windows KitOS Windows Windows Linux Original Windows Linux Windows Original 0 200 400 600 800 1000 1200 1400 UDP Packet Size (Bytes)

Performance Throughput (Mbps) 100 80 60 40 20 0 Windows KitOS Windows Windows Linux Original Windows Linux Windows Original 0 200 400 600 800 1000 1200 1400 UDP Packet Size (Bytes)

PorDng Effort

PorDng Effort Virtual Machine Guest OS Original Binary Driver 80% basic block coverage ~20 min Zero manual effort Driver Exerciser

PorDng Effort Virtual Machine Guest OS Original Binary Driver 80% basic block coverage ~20 min Zero manual effort Driver Exerciser ~1 min RevNIC Code Synthesizer Zero manual effort

PorDng Effort Virtual Machine Guest OS Original Binary Driver Driver Exerciser 80% basic block coverage ~20 min Zero manual effort Few hours 5 days ~1 min RevNIC Code Synthesizer One Dme effort NIC Driver Template Zero manual effort

PorDng Effort Virtual Machine Guest OS Original Binary Driver Driver Exerciser 80% basic block coverage ~20 min Zero manual effort Few hours 5 days ~1 min RevNIC Code Synthesizer One Dme effort NIC Driver Template Zero manual effort SyntheDc Driver (e.g., Linux)

PorDng Effort RevNIC speeds up driver development Device Manual (Linux) RevNIC Persons Span Persons Span RTL8139 18 4 years 1 1 week 91C111 8 4 years 1 4 days NE2000 5 2 years 1 5 days PCNet 3 4 years 1 1 week

PorDng Effort RevNIC speeds up driver development Device Manual (Linux) RevNIC Persons Span Persons Span RTL8139 18 4 years 1 1 week 91C111 8 4 years 1 4 days NE2000 5 2 years 1 5 days PCNet 3 4 years 1 1 week

PorDng Effort RevNIC speeds up driver development Device Manual (Linux) RevNIC Persons Span Persons Span RTL8139 18 4 years 1 1 week Mostly fixing undocumented quirks 91C111 8 4 years 1 4 days NE2000 5 2 years 1 5 days PCNet 3 4 years 1 1 week

PorDng Effort RevNIC speeds up driver development Device Manual (Linux) RevNIC Persons Span Persons Span RTL8139 18 4 years 1 1 week 91C111 8 4 years 1 4 days NE2000 5 2 years 1 5 days PCNet 3 4 years 1 1 week

RevNIC Reverse engineering of driver s state machine from interacdon traces High coverage reverse engineering through symbolic execudon Using symbolic hardware for reverse engineering without access to original devices

RevNIC Reverse engineering of driver s state machine from interacdon traces High coverage reverse engineering through symbolic execudon Using symbolic hardware for reverse engineering without access to original devices http://reveng.epfl.ch