Provably Secure Execution Platforms
- Lecture Four:
A Simple Separation Kernel and Its Verification
Mads Dam
KTH Royal Institute of Technology
BISS spring school, Bertinoro 2018
Provably Secure Execution Platforms - Lecture Four: A Simple - - PowerPoint PPT Presentation
Provably Secure Execution Platforms - Lecture Four: A Simple Separation Kernel and Its Verification Mads Dam KTH Royal Institute of Technology BISS spring school, Bertinoro 2018 The Goal Hypervisor Context switch: Fixed round-robin
Mads Dam
KTH Royal Institute of Technology
BISS spring school, Bertinoro 2018
guests, statically allocated
Hypervisor
Dam, Guanciale, Khakpour, Nemati, Schwarz: Formal Verification of Information Flow Security for a Simple ARM-Based Separation Kernel, CCS’13
Q: What is a kernel? A: A set of event handlers and some data structures for support Three types of events:
– arise as result of a processor error conditions
– arise when a user program wants to invoke some service
– Arise when a piece of hardware (e.g. USB device, NIC, …) wants to invoke some service
Upon an event a handler routine is invoked, user state stored on stack and privilege level is raised Upon return user state is restored – In some suitable form Parameters transferred in registers – When applicable … Results returned in registers – When applicable … During handler execution, exceptions and interrupt may be disabled or not – Non-preemptive kernel: No nesting of interrupts Our kernel is preemptive
Describes the abstract functionality of the system, here:
level functionality
by ideal handlers
guests through communication and instruction cycle counting
CPU CPU
Context switching:
time Sending a message:
reg 0 to be written to msgbox Receiving a message:
instead of restoring receiver invoke user level handler Restoring receiver:
invoke swi 0 to restore receiver
CPU CPU
: Normal sender execution : Message processing : Send hypercall : Resume hypercall : Normal receiver execution
Scheduling round
Sender Receiver Scheduler
Ideal model state:
Messaging data structures:
between message processing and normal execution
Context fields are stored consecutively in memory is field accessor is field update Also use tuple notation:
Initial state :
– Registers zeroed – initialized to make the user address spaces disjoint and not contain the vector jump addresses – suitably initialized within user address space – initialized to suitably large number (return to that)
, for suitable
These are defined later
User step: User step, symmetric case: Many symmetric cases below, mostly omitted
Guest switch, message processing in progress:
Guest switch, no message pending:
Some helper functions:
Guest switch, receive message:
Entry points for guest 0/guest 1 message handlers
Guest resume:
Guest send:
Exercise 1: Convince yourself that the transition semantics makes sense by mentally executing a few simple scenarios (and report to me any bugs you find!) Exercise 2: Prove some simple sanity properties, such as:
reachable from the initial state): – At most one of is in privileged state – If is in privileged state then ’s program counter is jump vector address – Stack pointers differ from their initial values only when one
Exercise 3: Does the transition semantics pose any constraints on the choice of ? Exercise 4 (harder): Devise a ”single-sided” semantics in which
transition labelled IO. States would have the shape . For transitions we would have a user transition: For privileged transitions, e.g.:
Exercise 4, continued: Show that for each trace of the ideal system there exists a corresponding pair of traces in the single-sided system such that the sequence of words exchanged in the ideal system trace corresponds to the sequence of words input, respectively
Exercise 5: Propose an ideal model transition rule for exceptions. You may assume a pair of guest exception handler entry points fooo , . The exception handler needs to receive as parameter in register 0 the address of the offending instruction.
Task:
handlers)
represented as code executing at privileged level
channels, stacks) to be explicitly represented in memory
Hypervisor
Two partitions/guests Execute in disjoint memory regions
is active when Kernel memory regions
– Contains exception and interrupt jump addresses
– Contains kernel code and data structures ,…: Kernel addresses holding the corresponding values
Guest entry points: – – Guest message handlers: – – Guest exception handlers: – –
Contexts: – ref /* ”Normal” context for guest 0 – ref /* Do. For guest 1
Stack roots: – – – – Each stack assigned a memory region with delimiters in: – – – –
Size?
Channels: – /* ? /* Resume context – –
In kernel memory: – – – – – In vector region: – – – –
Processor initialised with: – Register 0,…,3, mode, time zeroed – – – , ??? – , –
,
transition rules of lecture 3
– Extract state information:
determine what action to take. – Update state: Channels, contexts – Prepare stack – Return from exception loads registers including pc in one atomic (!) step
Show irq_entry.pseudo, swi1_entry (mask). (Find them in the course directory) Exercise 6. Give similar pseudo-code implementations of the
Exercise 7. Find a suitable Hoare-style specification of the irq_entry routine. Use weakest preconditions to show that it holds, under the assumption that it is never preempted.
Exercise 8. t_sw1, t_sw2, t_rcv, t_res, t_send: The ideal model transition rules leave these numbers unspecified. Explain how to calculate them, and estimate t_rcv. Exercise 9. t_max: We have also left t_max unspecified. Propose a lower bound. Exercise 10. Stacks: Stacks can grow in an unbounded fashion in pathological cases. Present a simple condition that will prevent stacks from growing larger than 2|ctx|.
Goal: – Want to prove that, when running on top of the kernel, the two guest systems do not interfere in unintended ways. – What does ”interfere” mean? – What does ”in unintended ways” mean?
Hypervisor
Proposal #1: Noninterference Can adapt definition of noninterference mod system variables, lecture 2, in the following way:
– High variables – content of guest 1 memory – System variables – content of kernel memory – Low variables – content of guest 0 memory
– Content of low memory + activity of guest
– Kernel (content of kernel memory) is NI, if whenever started in states s_0,s_1 for which kernel and low variables are identical, the observations are the same
When is a guest active?
Pictorially:
Hypervisor Hypervisor
machine state are identical
Separation kernel CPU CPU CPU
Separation kernel CPU CPU CPU
CPU
CPU (By ”our approach”) (By ”our approach”) (Since there is no communication)
– , , , , III , , etc. – , etc. – , whenever – (same for guest 1 memory) – , etc. – iff guest 0 scheduled in
and real model
Trace of ideal model: Trace of real model: Show that:
1 2 n n+1
1 2 n n+1
Like the ”NI modulo system variables” notion from lecture 2 Define relation on states in ideal and real model as for the initial states: – iff – Observations of guest in = observations of guest in and the system states are suitably related – Guest is scheduled in iff guest is scheduled in IIIIIIII , the channel states in the guest systems are ”compatible”, etc. etc. Exercise 11: Propose a suitable definition of . In particular, what to do about time?
Identical:
Ide Weak bisimulation
Ide Weak bisimulation
Ide Boot Lemma
states
Ide User Lemma
Ide Switch Lemma
Ide Handler Lemmas
Suppose again Suppose that and are both in user mode Switch Lemma: if and is in privileged mode then in privileged mode and , and vice versa Exercise 13: Prove the Switch Lemma for one or two cases using again the relational method.
Suppose again Suppose that and are both in privileged mode Let , if the execution of the handler invoked in ”returns to the state” IIIIII Handler Lemma: if and is in privileged mode then and IIII , and vice versa Exercise 13: Prove the Handler Lemma for irq_entry using the Hoare specification obtained in exercise 7 with some additional reasoning.
The relation induces a bijective correspondence over paths in the ideal and real models Exercise 14. Show this. We obtain the following lemma: TEL Preservation Lemma. For each pair of points in the ideal and real models respectively, such that IIIII , if then . Exercise 15. Prove the TEL Preservation Lemma
In particular we can show:
model if and only if it is valid in the real model Since we view TEL as a sort of canonical security logic the above corollary serves as the key justification for our approach. For instance, if we can show in the ideal model that no information dependent on any bit in some key K ever leaves guest 0, then the same holds for the real model.
We glossed over preemption Preemption: An exception handler is interrupted by some other exception (This is avoided in most real kernels AFAIK) We have the following handlers: – irq, scheduling – swi0, resume – swi1, send – exn, exceptions
Let if can preempt Who can preempt who? And when? – irq irq? – exn exn? – swi0 swi0? swi1 swi1? – exn swi0? exn swi1? exn irq? – swi0 exn? swi0 swi1? swi0 irq? swi1 exn? Etc? – irq exn? irq swi0? irq swi1? Some combinations can be ruled out using reasonable design goals What about the other cases?
Show that: Behaves as if either: Or:
Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0
Identify linearisation points Points where call ”takes effect” Show that execution steps can be commuted
Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0
Identify linearisation points Points where call ”takes effect” Show that execution steps can be commuted
Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0
Identify linearisation points Points where call ”takes effect” Show that execution steps can be commuted
Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0
Identify linearisation points Points where call ”takes effect” Show that execution steps can be commuted
Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0
Identify linearisation points Points where call ”takes effect” Show that execution steps can be commuted
Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0
Identify linearisation points Points where call ”takes effect” Show that execution steps can be commuted Without affecting observations
Guest 1 Guest 2 irq swi0 Guest 1 Guest 2 irq swi0
Show irq_entry.pseudo and swi1_entry.pseudo as examples Exercise 16: Show linearisability of irq vs swi0. Will interrupt masking be needed?
Processor Memory Input Device
Memory ”bus” Interrupt Input
The task is to extend the model with an input device which uses an interrupt to signal the presence of new input, similar to a rudimentary unidirectional USB device. The device receives external input on a channel . We treat external input abstractly, and just assume a function that returns the next 32 bit word available on an unspecified input stream, which is not necessary to include in the model. The device delivers the input to the processor through Direct Memory Access (DMA), that is, the device is able to autonomously write its input to a preselected memory address. This is obviously highly dangerous in a virtualised context, which is why this exercise is of interest. The device will have one or more memory mapped registers
The device is configured using memory mapped registers. I could imagine two such registers:
location, but potentially with side effects that may cause the internal state of the device to change. Often, the memory- mapped locations are RO or WO. Here, you can ignore this and just assume, e.g., that a write to a naturally RO/WO register has no effect.
Initially, the input device is disabled ( ). Enabledness status is changed by writing to the register. If the device finds an input available in the input stream and DMA is enabled, the device may choose to write the next input word to the address found in the register . Simultaneously, it will disable itself and interrupt the processor to signal the presence of a new input word. One of the two guest will own the device, i.e. its control registers will be located in the chosen guests memory area.
The tasks are the following:
asynchronously with the processor itself. That is, progress in the processor should not be tied to the device nor vice versa. You may need a scheduler to resolve choices in your
forget that the existing SPM1 transition rules may have to be looked at again. The ambitious student might want to think about the granularity of your model: Memory accesses are not usually performed as atomic lookups, but instead by first exposing the address to the memory system and then reading the data.
it is the guest that should ”run” the device, not the
hypervisor-guest interface.
functionality/functionalities, devise a proof strategy following the ideas presented in the lecture, and complete a reasonable portion of the proofs.