Prevail: Simple and Precise Static Analysis of Untrusted Linux Kernel Extensions This work is about static analysis of kernel extensions, also known as.

Slides:



Advertisements
Similar presentations
Alan Shaffer, Mikhail Auguston, Cynthia Irvine, Tim Levin The 7th OOPSLA Workshop on Domain-Specific Modeling October 21-22, 2007 Toward a Security Domain.
Advertisements

A Program Transformation For Faster Goal-Directed Search Akash Lal, Shaz Qadeer Microsoft Research.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Native x86 Decompilation Using Semantics-Preserving Structural Analysis and Iterative Control-Flow Structuring Edward J. Schwartz *, JongHyup Lee ✝, Maverick.
Analyzing and Improving Linux Kernel Memory Protection A Model Checking Approach ACSAC 2010 Siarhei Liakh, North Carolina State University Michael Grace,
01/05/2015Leiden Institute of Advanced Computer Science 1 The Open Kernel Environment - spinning Linux - Herbert Bos Bart Samwel
EXTENSIBILITY, SAFETY AND PERFORMANCE IN THE SPIN OPERATING SYSTEM B. Bershad, S. Savage, P. Pardyak, E. G. Sirer, D. Becker, M. Fiuczynski, C. Chambers,
Whole-Program Linear-Constant Analysis with Applications to Link-Time Optimization Ludo Van Put – Dominique Chanet – Koen De Bosschere Ghent University.
1 Mechanical Verification of Timed Automata Myla Archer and Constance Heitmeyer Presented by Rasa Bonyadlou 24 October 2002.
May 7, A Real Problem  What if you wanted to run a program that needs more memory than you have?
1 A Real Problem  What if you wanted to run a program that needs more memory than you have?
Secure web browsers, malicious hardware, and hardware support for binary translation Sam King.
Vertically Integrated Analysis and Transformation for Embedded Software John Regehr University of Utah.
Program analysis Mooly Sagiv html://
Programmability with Proof-Carrying Code George C. Necula University of California Berkeley Peter Lee Carnegie Mellon University.
Program analysis Mooly Sagiv html://
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
PhD/Master course, Uppsala  Understanding the interaction between your program and computer  Structuring the code  Optimizing the code  Debugging.
Overview of program analysis Mooly Sagiv html://
Run-time Environment and Program Organization
Scalable and Flexible Static Analysis of Flight-Critical Software Guillaume P. Brat Arnaud J. Venet Carnegie.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Efficient Software-Based Fault Isolation—sandboxing Presented by Carl Yao.
Secure Virtual Architecture John Criswell, Arushi Aggarwal, Andrew Lenharth, Dinakar Dhurjati, and Vikram Adve University of Illinois at Urbana-Champaign.
Microkernels, virtualization, exokernels Tutorial 1 – CSC469.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
Lecture 2 Foundations and Definitions Processes/Threads.
CS 211: Computer Architecture Lecture 6 Module 2 Exploiting Instruction Level Parallelism with Software Approaches Instructor: Morris Lancaster.
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Page 1 5/2/2007  Kestrel Technology LLC A Tutorial on Abstract Interpretation as the Theoretical Foundation of CodeHawk  Arnaud Venet Kestrel Technology.
Semantics In Text: Chapter 3.
More on Correctness. Prime Factorization Problem: Write a program that computes all the prime factors of a given number Solution (Idea): Factors are less.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
Efficient Software Based Fault Isolation Author: Robert Wahobe,Steven Lucco,Thomas E Anderson, Susan L Graham Presenter: Maitree kanungo Date:02/17/2010.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
Static Identification of Delinquent Loads V.M. Panait A. Sasturkar W.-F. Fong.
Exploiting Instruction Streams To Prevent Intrusion Milena Milenkovic.
Efficient Software-Based Fault Isolation Authors: Robert Wahbe Steven Lucco Thomas E. Anderson Susan L. Graham Presenter: Gregory Netland.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
Kernel Modules – Introduction CSC/ECE 573, Sections 001 Fall, 2012.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Introduction to Operating Systems Concepts
Efficient Software-Based Fault Isolation
Introduction to Operating Systems
Seminar in automatic tools for analyzing programs with dynamic memory
Von Neumann model - Memory
Verifying REACT Aleks Milisevic Will Noble Martin Rinard
Introduction to the Kernel and Device Drivers
An Introduction to Device Drivers
Symbolic Implementation of the Best Transformer
Introduction to Operating Systems
The Operating System Memory Manager
AdaCore Technologies for Cyber Security
All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, Thanassis.
Applied Discrete Mathematics Week 6: Computation
Lecture Topics: 11/1 General Operating System Concepts Processes
Von Neumann model - Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
The Design & Implementation of Hyperupcalls
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CS510 Operating System Foundations
System calls….. C-program->POSIX call
Foundations and Definitions
Cache writes and examples
Carmine Abate Rob Blanco Deepak Garg Cătălin Hrițcu Jérémy Thibault
Dynamic Binary Translators and Instrumenters
Presentation transcript:

Prevail: Simple and Precise Static Analysis of Untrusted Linux Kernel Extensions This work is about static analysis of kernel extensions, also known as eBPF programs Hila: * Don’t undersell * (Jonathan van Geffen) 7 minutes for the problem domain DSL like x86 Example before No cBPF Motivation: only packet filtering in the start, the rest at the end Don’t talk about join Supporting loops ”as well as current AI allows” – more than no-loop verifier Kalev Don’t undersell More emphasis on our work Explicit point where we say that we wrote a verifier Problem - Existing solution –Our solution: SEPARATE slide Mention the name: PREVAIL Mention the library explicitly ”Example of a bad case” Detailed empirical: “Spurious“ in context Precision: more details Track: copy? Explain desired behavior before introducing solution Say: code in kernel can take control on everything eBPF Programs Elazar Gershuni, Noam Rinetzky, Mooly Sagiv (TAU) Leonid Ryzhyk, Nadav Amit, Nina Narodytska (VMWare Research) Jorge A. Navas (SRI International) Arie Gurfinkel (University of Waterloo)

Static Analysis: Success Stories Device drivers (Slam, Blast) Avionics (Astrée, CGS) OS kernel extensions eBPF Restricted class of programs Safety is crucial Particular properties Verification is already mandatory Programming for verifiability Better analysis  more programs If you look at successful applications of static analysis you will see that they share a common theme: They typically focus on a restricted class of programs and a restricted set of properties that are crucial for the safety of the whole system. This work is about a new application domain for static analysis, for which all of the above is true, along with an additional feature: here, verification allows people to do things they cannot do otherwise. And we know that people want to do those things, because there is already a verifier for eBPF programs inside the Linux kernel, and people are already writing code that must pass verification. But the Linux verifier has important shortcoming; we present

PREVAIL: a new eBPF verifier Simple Scalable Precise in practice Improves functionality over existing verifier PREVAIL - a new eBPF verifier that is simple, scalable, precise enough to analyze existing programs and is better than the current verifier in several important factors. But first, let’s talk about the domain – what are kernel extensions?

What are Kernel Extensions? process kernel Packet filters Security policies Profiling ... P Filter

eBPF Arithmetic Load/Store Jmp Kernel API r0 start end Context r1 r2 Packet r3 r4 Shared … r10 Stack 512 bytes

Running Example: Packet Filter start end Context r2 = *(u32*)(r1 + 0) r3 = r2 + 8 r4 = *(u32*)(r1 + 4) if r3 > r4 exit 1 r5 = *(u64*)(r2) if r5 = 0 exit 1 exit 0 r1 r2 Packet r3 r4 Shared … r10 Stack

Execution model: Compilation process kernel compiler P Trust boundary is only crossed once, at load time eBPF x86

Execution model: Verification + Compilation process kernel verifier compiler P Trust boundary is only crossed once, at load time eBPF x86

What to Verify? Absence of memory errors No leakage of kernel addresses Termination What’s not to verify: functional correctness

current (Linux) Verifier Path enumeration Heuristic pruning Intervals, bit values, identities Looks for specific patterns Lacks formal foundations – particularly with respect to the heuristics.

Current (Linux) Verifier No formal foundations No loops Exponential r2 = packet_start while r2 < packet_end … r2 ++ Lacks formal foundations – particularly with respect to the heuristics.

Prevail Based on abstract interpretation Loops Cubic in theory Focus on safety properties Loops Cubic in theory Linear in practice Bla blab. Next I will show examples that guided the main design decisions of our verifier.

Modeling PACKET ACCESSES Relational invariants Code Invariants r2 = pkt_start r3 = r2 + 8 r4 = pkt_end if r3 > r4 exit 1 r5 = *(u64*)(r2) 𝑟2↦(𝑝𝑘𝑡,0) 𝑟3↦ 𝑝𝑘𝑡,8 𝑟4↦ 𝑝𝑘𝑡,? 𝑟3=𝑟2+8 𝑟4=𝑒𝑛𝑑 𝑟3≤𝑟4 𝑟2≤𝑟4−8 𝟎≤𝒓𝟐≤𝒆𝒏𝒅−𝟖

Modeling Register Spilling Relational invariants Code Invariants r2 = pkt_start r3 = r2 + 8 r4 = pkt_end *(stack+16) = r2 r2 = 0 if r3 > r4 exit 1 r6 = *(stack+16) r5 = *(u64*)(r6) 𝑟2↦(𝑝𝑘𝑡,0) 𝑟3↦ 𝑝𝑘𝑡,8 𝑟4↦ 𝑝𝑘𝑡,? 𝑟2↦ 𝑛𝑢𝑚,0 𝑟3=𝑟2+8 𝑟4=𝑒𝑛𝑑 𝑟3=𝑆 16..23 +8 𝑟3≤𝑟4 𝑆 16..23 ≤𝑟4−8 0≤𝑆 16..23 ≤𝑒𝑛𝑑−8 𝟎≤𝒓𝟔≤𝒆𝒏𝒅−𝟖

Memory Abstract Domain Code Invariants *(stack + 8) = r2 *(stack + 0) = r1 *(stack + 4) = r3 S 8:15 =𝑟2 S 8:15 =𝑟2∧𝑆 0:7 =𝑟1 S 4:11 =𝑟3 Let’s Specifics about how we model register spilling r10 S[0:7] S[4:11] S[8:15] Stack

Parametric Abstract Domain 𝑅𝑒𝑔= 𝑟 0 ,…, 𝑟 10 ,𝑠𝑡𝑎𝑟𝑡,𝑒𝑛𝑑 𝐶𝑒𝑙𝑙= 𝑖,𝑗 |𝑖∈ 0,511 ∧𝑗∈ 1, 8 D T : abstract domain for finite sets D N : abstract numerical domain Σ # = 𝐷 𝑇 𝑅𝑒𝑔 ∪ 𝐶𝑒𝑙𝑙 × 𝐷 𝑁 𝑅𝑒𝑔∪ 𝐶𝑒𝑙𝑙 × 2 𝐶𝑒𝑙𝑙 × 2 0,511 // regions // offsets // spilled registers // unclassified bytes

Evaluation 192 programs from real-world projects Linux, Cilium, OpenVSwitch, Suricata Number of instructions: 2-3500 All (currently) pass the Linux verifier

Numerical Domain Menu Interval: c 1 ≤𝑉≤ 𝑐 2 Zone: 𝑽 𝟏 − 𝑽 𝟐 ≤𝑲 Octagon: ±𝑉 1 ±𝑉 2 ≤𝐾 Polyhedra: Σ i 𝑐 𝑖 𝑉 𝑖 ≤𝐾

Precision Interval: 66% (128/192) Zone, Octagon: 99% (191/192) Polyhedra: 89% (170/192) Generates large coefficients that cannot be represented in 64 bits

sec Runtime 20 10 5 1000 2000 3000 Instructions

GB Memory 4 3 2 1 1000 2000 3000 Instructions

Linux vs Prevail Code: strncmp(a,b,K) Sec 15 10 Linux 5 Prevail 20 40 20 40 60 K

Conclusions Verification of kernel extensions is in industrial use Abstract interpretation is even better An opportunity for the verification community

Formal Verification as an enabler github.com/vbpf/ebpf-verifier