Sel4: Formal Verification of an OS Kernel

Sel4: Formal Verification of an OS Kernel

seL4: Formal Verification of an OS Kernel Gerwin Klein1;2, Kevin Elphinstone1;2, Gernot Heiser1;2;3 June Andronick1;2, David Cock1, Philip Derrin1∗, Dhammika Elkaduwe1;2,z Kai Engelhardt1;2 Rafal Kolanski1;2, Michael Norrish1;4, Thomas Sewell1, Harvey Tuch1;2y, Simon Winwood1;2 1 NICTA, 2 UNSW, 3 Open Kernel Labs, 4 ANU [email protected] Abstract proach is to reduce the amount of privileged code, Complete formal verification is the only known way in order to minimise the exposure to bugs. This is to guarantee that a system is free of programming a primary motivation behind security kernels and errors. separation kernels [38, 54], the MILS approach [4], We present our experience in performing the for- microkernels [1, 12, 35, 45, 57, 71] and isolation ker- mal, machine-checked verification of the seL4 mi- nels [69], the use of small hypervisors as a minimal crokernel from an abstract specification down to its trust base [16,26,56,59], as well as systems that re- C implementation. We assume correctness of com- quire the use of type-safe languages for all code except piler, assembly code, and hardware, and we used a some \dirty" core [7,23]. Similarly, the Common Cri- unique design approach that fuses formal and oper- teria [66] at the strictest evaluation level requires the ating systems techniques. To our knowledge, this is system under evaluation to have a \simple" design. the first formal proof of functional correctness of a With truly small kernels it becomes possible to take complete, general-purpose operating-system kernel. security and robustness further, to the point where Functional correctness means here that the implemen- it is possible to guarantee the absence of bugs [22, tation always strictly follows our high-level abstract 36,56,64]. This can be achieved by formal, machine- specification of kernel behaviour. This encompasses checked verification, providing mathematical proof traditional design and implementation safety proper- that the kernel implementation is consistent with ties such as the kernel will never crash, and it will its specification and free from programmer-induced never perform an unsafe operation. It also proves implementation defects. much more: we can predict precisely how the kernel We present seL4, a member of the L4 [46] microker- will behave in every possible situation. nel family, designed to provide this ultimate degree seL4, a third-generation microkernel of L4 prove- of assurance of functional correctness by machine- nance, comprises 8,700 lines of C code and 600 lines assisted and machine-checked formal proof. We have of assembler. Its performance is comparable to other shown the correctness of a very detailed, low-level high-performance L4 kernels. design of seL4 and we have formally verified its C 1 Introduction implementation. We assume the correctness of the The security and reliability of a computer system compiler, assembly code, boot code, management of can only be as good as that of the underlying oper- caches, and the hardware; we prove everything else. ating system (OS) kernel. The kernel, defined as the Specifically, seL4 achieves the following: part of the system executing in the most privileged • it is suitable for real-life use, and able to achieve mode of the processor, has unlimited hardware access. performance that is comparable with the best- Therefore, any fault in the kernel's implementation performing microkernels; has the potential to undermine the correct operation • its behaviour is precisely formally specified at of the rest of the system. an abstract level; General wisdom has it that bugs in any sizeable • its formal design is used to prove desirable code base are inevitable. As a consequence, when properties, including termination and execution security or reliability is paramount, the usual ap- safety; Philip Derrin is now at Open Kernel Labs. • its implementation is formally proven to satisfy ∗ the specification; and yHarvey Tuch is now at VMware. zDhammika Elkaduwe is now at University of Peradeniya • its access control mechanism is formally proven 1 to provide strong security guarantees. also propagated via IPC to support virtualisation. To our knowledge, seL4 is the first-ever general- IPC uses synchronous and asynchronous endpoints purpose OS kernel that is fully formally verified for (port-like destinations without in-kernel buffering) functional correctness. As such, it is a platform of for inter-thread communication, with RPC facilitated unprecedented trustworthiness, which will allow the via reply capabilities. Capabilities are segregated and construction of highly secure and reliable systems on stored in capability address spaces composed of ca- top. pability container objects called CNodes. The functional-correctness property we prove for As in traditional L4 kernels, seL4 device drivers run seL4 is much stronger and more precise than what as normal user-mode applications that have access automated techniques like model checking, static to device registers and memory either by mapping analysis or kernel implementations in type-safe lan- the device into the virtual address space, or by con- guages can achieve. We not only analyse specific trolled access to device ports on Intel x86 hardware. aspects of the kernel, such as safe execution, but also seL4 provides a mechanism to receive notification of provide a full specification and proof for the kernel's interrupts (via IPC) and acknowledge their receipt. precise behaviour. Memory management in seL4 is explicit: both in- We have created a methodology for rapid kernel de- kernel objects and virtual address spaces are pro- sign and implementation that is a fusion of traditional tected and managed via capabilities. Physical mem- operating systems and formal methods techniques. ory is initially represented by untyped capabilities, We found that our verification focus improved the which can be subdivided or retyped into kernel objects design and was surprisingly often not in conflict with such as page tables, thread control blocks, CNodes, achieving performance. endpoints, and frames (for mapping in virtual ad- In this paper, we present the design of seL4, discuss dress spaces). The model guarantees all memory the methodologies we used, and provide an overview allocation in the kernel is explicit and authorised. of the approach used in the formal verification from Initial development of seL4, and all verification high-level specification to the C implementation. We work, was done for an ARMv6-based platform, with also discuss the lessons we have learnt from the a subsequent port of the kernel (so far without proof) project, and the implications for similar efforts. to x86. The remainder of this paper is structured as fol- 2.2 Kernel design process lows. In Sect. 2, we give an overview of seL4, of the OS developers tend to take a bottom-up approach to design approach, and of the verification approach. In kernel design. High performance is obtained by man- Sect. 3, we describe how to design a kernel for formal aging the hardware efficiently, which leads to designs verification. In Sect. 4, we describe precisely what motivated by low-level details. In contrast, formal we verified, and identify the assumptions we make. methods practitioners tend toward top-down design, In Sect. 5, we describe important lessons we learnt as proof tractability is determined by system com- in this project, and in Sect. 6, we contrast our effort plexity. This leads to designs based on simple models with related work. with a high degree of abstraction from hardware. As a compromise that blends both views, we 2 Overview adopted an approach [19, 22] based around an in- 2.1 seL4 programming model termediate target that is readily accessible by both This paper is primarily about the formal verification OS developers and formal methods practitioners. It of the seL4 kernel, not its API design. We therefore uses the functional programming language Haskell to provide only a brief overview of its main characteris- provide a programming language for OS developers, tics. while at the same time providing an artefact that can seL4 [20], similarly to projects at Johns Hopkins be automatically translated into the theorem proving (Coyotos) and Dresden (Nova), is a third-generation tool and reasoned about. microkernel, and is broadly based on L4 [46] and Fig. 1 shows our approach in more detail. The influenced by EROS [58]. It features abstractions for square boxes are formal artefacts that have a direct virtual address spaces, threads, inter-process commu- role in the proof. The double arrows represent imple- nication (IPC), and, unlike most L4 kernels, capabili- mentation or proof effort, the single arrows represent ties for authorisation. Virtual address spaces have no design/implementation influence of artefacts on other kernel-defined structure; page faults are propagated artefacts. The central artefact is the Haskell proto- via IPC to pager threads, responsible for defining type of the kernel. The prototype requires the design the address space by mapping frames into the virtual and implementation of algorithms that manage the space. Exceptions and non-native system calls are low-level hardware details. To execute the Haskell Design Cycle Isabelle/HOL Design Abstract Specification Hardware Haskell Executable Specification Haskell Prototype Formal Executable Spec Simulator + Prototype Manual Proof Implementation Automatic Translation High-Performance C Implementation Refinement Proof User Programs High-Performance C Implementation Figure 1: The seL4 design process Figure 2: The refinement layers in the verification of seL4 prototype in a near-to-realistic setting, we link it with software (derived from QEMU) that simulates opportunities to micro-optimise the kernel, which is the hardware platform. Normal user-level execution required for adequate microkernel performance. is enabled by the simulator, while traps are passed 2.3 Formal verification to the kernel model which computes the result of The technique we use for formal verification is inter- the trap. The prototype modifies the user-level state active, machine-assisted and machine-checked proof.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us