Setting
A sensor gateway is a small device that collects readings from sensors and passes them on. The gateway in this invented example is built on a microcontroller unit §6.1 (MCU): a single chip that holds a processor, its memory and peripherals such as a radio. It accepts a small decision program, delivered through a phone from a publisher, the one party authorized to change the gateway’s rules. The gateway’s own software, the host, runs the decision program, the guest, inside a virtual machine §2.3 (VM), a part of the host that carries out the guest’s instructions one at a time and checks each guest memory access.
The host is one compiled program. It contains a small real-time operating system (RTOS) kernel, which schedules threads, the independently scheduled sequences of execution; a Bluetooth Low Energy (BLE) §7.1 protocol stack, which runs the radio protocol; the VM; and the helper functions §2.19, host routines that the guest may call. All of it runs in one address space, meaning that every part can name every memory address, and all of it runs at the processor’s privileged level, which may configure the hardware. The MCU has no memory management unit §6.9 (MMU), the hardware that gives each process on a desktop computer its own address space. It has a memory protection unit §6.8 (MPU), which can restrict access to a few address ranges, but here the MPU is not configured. A direct memory access §4.36 (DMA) engine copies radio data into memory, and interrupts §6.11, hardware signals that make the processor suspend the current code and run a handler, can arrive at any time.
Short answer
Without process isolation, every native part of the host can read and write all memory, so all of it must be trusted. The guest stays confined only because the VM checks each guest access in software. No boundary stops a bug in the radio stack, the kernel, the VM or a helper; separate threads isolate nothing; and DMA engines and interrupt handlers §6.12 act outside the VM’s checks. Hardware faults and power loss lie outside any software proof and need their own arguments.
Follow-up questions
First answer
The downloaded program can still be isolated, but nothing else is: the only boundary is the checking done by the virtual machine (VM) that runs the program, and every native component is trusted. On a desktop operating system each program runs as a process with its own address space, enforced by a memory management unit (MMU), so a bug in one process cannot write another’s memory. A microcontroller unit (MCU) that runs all its software as one program, in one address space and at one privilege level §6.10, has no such boundary.
The guest can stay confined. If the VM checks every address that the downloaded program, the guest, uses, and checks it before the access happens, the guest cannot reach other memory. This is software fault isolation §2.41: isolation enforced by checks in software instead of by hardware.
Every native component can reach all memory. A bug in the Bluetooth Low Energy (BLE) protocol stack can overwrite the VM’s record of the guest’s region limits, or the guest’s instructions after they were checked. The guest’s confinement depends on the correctness of all native code, which therefore all belongs to the trusted computing base §1.4.
A thread is not a boundary. Threads, the independently scheduled sequences of execution, share the address space and the privilege level. A scheduler decides when code runs, not what memory it can touch, so running the VM in a thread of its own adds no memory isolation.
Hardware can restore some boundaries if it is configured. A memory protection unit (MPU) can make code read-only, place a protected region beyond the end of each stack, or let selected threads run at the unprivileged level with access to their own regions only. Only boundaries that are configured and enforced count.
Can a guest jump to arbitrary native code?
Not if the virtual machine (VM) controls every transfer of control that the downloaded program, the guest, can make. The guest has two kinds of transfer.
Jumps inside the guest program. A jump in the guest’s bytecode §2.4 moves to another instruction of the same program, at a position counted from the current one. The VM checks that the target lies inside the program, once before the run or at every jump, so no jump leaves the guest’s instructions.
Calls to helper functions, routines of the device’s own software offered to the guest. The guest names a helper by number, not by address. Before calling, the VM checks that the number is smaller than the size of its dispatch table §2.39, the table that maps numbers to helper addresses, that the entry is present, and that this guest may call that helper. With a 64-entry table, numbers 0 to 63 are valid; a request for helper 300 fails the test and is refused.
The guest reaches arbitrary native code only through a flaw in design or implementation:
the host accepts a native function address from the guest and calls it;
the table lookup lacks its bounds check: with 4-byte entries the table occupies bytes, yet number 300 reads the word bytes from its start, and the host calls whatever address that memory happens to hold;
a helper writes guest-chosen bytes into a function pointer, or into the vector table §6.14, the list of addresses the processor uses to find interrupt handlers, when that table lies in writable memory;
a just-in-time (JIT §2.14) compiler, which turns the guest’s bytecode into native instructions, emits wrong code.
Native code itself is outside this model. On a microcontroller where all native code runs at the privileged level, a compromised native component can rewrite the vector table or switch the memory protection hardware off.
What about DMA and interrupts?
Both act on memory without passing through the checks of the virtual machine (VM) that runs the downloaded program, so both must be modeled as separate actors. A check on the program’s loads and stores mediates neither.
Direct memory access (DMA) is done by a hardware engine that copies data between a peripheral, such as the radio, and memory without the processor executing each transfer. After the software starts a transfer into a buffer, the engine writes that buffer on its own schedule until the transfer completes.
A buffer handed to the program before the transfer completes changes while the program reads it, so two reads of one byte can return different values.
A buffer freed and reused before the transfer completes is overwritten by the engine: a use-after-free §4.6 carried out by hardware.
The VM’s checks see only the program’s instructions, and on many microcontrollers the memory protection unit (MPU) checks only accesses made by the processor, so neither restrains the engine.
On a processor with a data cache, the processor can read an old cached copy of bytes that the engine has replaced, unless the software invalidates the cache after the transfer.
The rule is that a buffer belongs either to the engine or to the software, never to both, and passes back to the software only when the transfer is known to be complete.
An interrupt service routine (ISR) is the function that runs when an interrupt, a hardware signal that suspends the current code, arrives. It can start between any two instructions of the thread it interrupts. If the thread has written an object’s new length but not yet its new data address, the ISR sees a half-updated object. A mutex §9.5, a lock that threads take in turn, does not help: an ISR must not wait, so it cannot take a mutex, and a mutex excludes only code that also takes it. The usual defenses are to disable that interrupt briefly around the update, or to prepare a complete new object and then publish it with a single indivisible write of one pointer. A compiler barrier §4.37 between the two steps keeps the compiler from moving the pointer write ahead of the writes that fill the object.
The model must therefore say, for every buffer, who owns it at each moment and when completion is signaled, and for every shared object, which actors can interrupt an update.
What if hardware faults or power fails?
Then a software proof no longer applies, because it assumes a processor and memory that behave as specified. A bounds proof says that, if every instruction executes as written, no access by the downloaded program leaves its region. It says nothing about:
power loss during a write to flash memory §6.6, which can leave a torn write §8.19, a record that is partly new and partly old;
a brownout §6.17, a sag of the supply voltage during which the processor may execute incorrectly before it is reset;
bit flips in memory, caused for example by radiation;
deliberate glitches of the supply voltage or the clock by an attacker with physical access.
Each admitted fault belongs in a fault model §1.30, a written list of the faults that the claims cover, and needs its own mechanism. Example: a record holds 8 bytes of data and a 4-byte cyclic redundancy check §4.32 (CRC), a checksum computed from the data. It is written as three 4-byte words, the CRC last, and power fails after the first word. The record now holds the new first half of the data, the old second half and the old CRC. Each half looks valid on its own, but the old CRC was computed from the old data, so it almost certainly does not match the mixture, and the boot code detects the torn record. Keeping two copies with a sequence number lets the boot code choose the newest complete copy. A brownout detector that holds the processor in reset while the voltage is too low, and a watchdog timer §6.16 that restarts a device that stops responding, cover further faults.
A clean software reset and a power loss are different tests. A software reset happens at a point the code chose, with no write in progress unless the code started one. A power loss can strike at any instruction, including in the middle of a flash write. Passing one test says nothing about the other.
Does fail-closed §1.13 always keep the device safe?
No. Fail closed means that when a check fails or cannot be completed, the system takes the restrictive outcome: it refuses the request, or keeps the old state instead of applying a change. It preserves one named property, that the protected action never happens without a successful check, and no other goal.
Availability §1.10. If a downloaded decision program fails and every failure counts as
DENY, the owner can no longer manage the device.Physical safety. Suppose the gateway relays commands to a valve, and a command to close the valve arrives while the check cannot run. Refusing the command leaves the valve open, which may be exactly the hazard. For an action that reduces danger, the safe default can be to perform it. Engineers call a design that fails into a harmless physical state fail-safe, which is not the same as fail-secure.
Recovery. If the only way to replace a faulty decision program passes through that program’s verdict, failing closed locks the owner out for good.
Before calling a default safe, state three things: which effect it protects, what refusing costs in each situation, and who keeps the authority to recover, by a path that the failing component cannot block.
Related entries: Memory protection unit (MPU) (§6.8), Memory management unit (MMU) (§6.9), Privilege level (§6.10), Interrupt (§6.11), Direct memory access (DMA) (§4.36).