Full name: Femto-Containers is a coined name, not an abbreviation. Femto is the metric prefix for one quadrillionth, ; container refers to the software containers of larger computers, such as those that Docker runs, which the paper names among the tools that do not fit microcontrollers §6.1.
What it is
Femto-Containers is a runtime, software that loads, isolates and runs other code, for small functions on microcontrollers: single-chip computers with tens to hundreds of kilobytes of memory. Each function is compiled to eBPF §2.1 (extended Berkeley Packet Filter) bytecode §2.4, instructions for a virtual machine §2.3, and the runtime executes it when a chosen event occurs, checking every memory access. Koen Zandberg, Emmanuel Baccelli, Shenghao Yuan, Frédéric Besson and Jean-Pierre Talpin published it at the Middleware conference in 2022. It addresses installing, updating and isolating such functions over a network.
Basis of this account
This account rests on the authors’ preprint, the version they posted on the public arXiv server: arXiv:2210.03432, version 1 of 7 October 2022. The preprint asks to be cited as the paper in the proceedings of the 23rd ACM/IFIP Middleware conference, November 2022, where ACM is the Association for Computing Machinery and IFIP the International Federation for Information Processing. The published text was not compared. The parts read were the abstract and the sections on use cases, threat model §1.2, design requirements, the comparison of candidate runtimes, the implementation, the example applications and the formal verification, together with the measurements of hook cost and of several containers on one device. The related work, the other measurements and the appendix were not examined. Nothing was run.
What the paper claims
The authors make these claims.
Purpose. They present Femto-Containers as “a new middleware runtime which can be embedded on heterogeneous low-power IoT devices” that enables “the secure deployment, execution and isolation of small virtual software functions” over the network. IoT means Internet of Things, and middleware is software that sits between the operating system and applications. They state that neither Linux nor a traditional hypervisor, a layer that runs several operating systems side by side, can serve as the software platform on microcontrollers, which have tens or hundreds of kilobytes of memory and no memory management unit §6.9 (MMU), the circuit that gives each program its own view of memory.
Choice of eBPF. On an Arm Cortex-M4 §6.3 microcontroller they compared four candidate runtimes, each running a Fletcher-32 checksum §4.32, a simple error-detecting sum, over 360 bytes. rBPF §2.17, the eBPF virtual machine of RIOT, an open-source operating system for small devices, needed 4.4 KiB of ROM (read-only memory, here flash) and 0.6 KiB of RAM. WASM3, an interpreter §2.13 for WebAssembly §19.5.6, needed 64 KiB and 85 KiB; MicroPython, a Python §12.23 interpreter, 101 KiB and 8.2 KiB; RIOTjs, a JavaScript runtime for RIOT, 121 KiB and 18 KiB. The operating system alone used 52.5 KiB and 16.3 KiB. rBPF started the function in 1 microsecond and ran it in 2133 microseconds, against 27 microseconds for native C code; WASM3 ran it in 980 microseconds but needed 17,096 microseconds to start. The authors chose eBPF for its memory use, its start-up time and the small size of its implementation, about 1,500 lines of code against 10,000 for WASM3.
Verified isolation. The interpreter and its pre-flight checker, about 500 lines of C, were formally verified in Coq, a proof assistant, that is, a program that checks every step of a proof, for fault isolation, “guaranteeing that RIOT is shielded from logic loaded and executed in a Femto-Container”. The verified version is named CertFC (Certified Femto-Container).
Small cost per function. Each further instance needs 624 bytes of RAM, including its 512-byte stack. Three containers belonging to two tenants, separate parties who each deploy code, ran in 3.2 KiB of RAM. On the Cortex-M4, a hook in the thread-switch path of RIOT, that is, a fixed point §3.22 in the operating system’s code at which attached functions run, cost 109 processor clock ticks when empty and 1750 with a function attached.
Portability. They implemented and evaluated Femto-Containers on Arm Cortex-M processors, on ESP32 chips from the company Espressif, and on RISC-V processors; RISC-V is an open instruction set whose name comes from RISC (reduced instruction set computer).
How it works
The firmware of RIOT contains fixed points at events such as the arrival of a network packet, a sensor reading, a timer or a switch between threads. The paper calls them hooks or launch pads §14.26. A hook fills a small context structure, for example with the identifiers of the previous and the next thread, and calls the hosting engine, the part of Femto-Containers that runs every function attached to that hook. Where the hook allows it, the function’s result changes what the firmware does next. A new function can be attached without changing the firmware; a new hook needs a firmware update.
One function goes through these steps.
Install. The bytecode arrives over CoAP (Constrained Application Protocol), a lightweight web protocol for small devices. It comes with a SUIT (Software Updates for Internet of Things) manifest §13.4, a signed description of the update that lets the device check its authenticity and integrity §1.9. The manifest names the hook by a unique identifier. The device downloads the new function into RAM before updating the hook to use it.
Pre-flight check. Before the first run, a checker reads every instruction. Each register field must name one of the eleven registers. Register
r10, which points to the function’s stack, must never be written. Every jump target must lie inside the function’s own code; the instruction set has no computed jumps, so every target is known before the run.Run. When the hook fires, the interpreter executes the instructions through a jump table §2.39 that holds one handler per operation code §2.8. The function has eleven 64-bit registers, a 512-byte stack and no heap. Nothing can break into the function’s own control flow, because the virtual machine offers no interrupts §6.11.
Memory check. A load or store computes its address at run time, so the interpreter compares every address with the function’s stack and with an allow list: memory regions that the host grants to this function, each marked readable, writable or both. A packet filter, for example, can be given read-only access to the packet. An access outside these regions aborts the run.
Limits. The engine limits the number of instructions in a function, , and the number of branch instructions that a run may execute, . The paper states that this bounds a run to instructions.
Host access. The function reaches peripherals and operating system services only through system calls, made with the eBPF call instruction. The paper calls the agreement between host and function a contract: the operating system offers a set of permissions at each hook, the function asks for a set, and the engine grants their intersection.
State. Values that must outlive a run, that is, guest persistent state §2.36, go into key-value stores, also reached through system calls. One store is private to the function, one is shared by all functions, and an optional third is shared by the functions of one tenant.
Worked example
The numbers are invented for teaching; the mechanism is the paper’s. A function attached to the packet hook may read a 64-byte packet that starts at address 0x20000400. Its allow list therefore holds one read-only region, addresses 0x20000400 to 0x2000043F.
A 2-byte load from
0x2000040Creads bytes 12 and 13 of the packet, because0x40Cminus0x400is 12. Both bytes lie inside the region, so the load proceeds.A 4-byte load from
0x2000043Ewould read bytes 62, 63, 64 and 65. Bytes 64 and 65 lie beyond the 64-byte region, so the run aborts.A 1-byte store to
0x20000410, byte 16, lies inside the region, but the region is read-only, so the run aborts.
Now take instructions and branch instructions, again invented values. Between two branch instructions the interpreter only moves forward, so one stretch of straight-line execution runs each of the at most 200 instructions at most once. A run has at most such stretches: one ending at each of the 100 permitted branches and one after the last. It therefore executes at most instructions. This is the paper’s product, , plus the final stretch. If one interpreted instruction took 1 microsecond, an invented figure, the run would end within about 20.2 milliseconds. Time spent inside system calls comes on top: a system call is one counted instruction, but its native code runs outside the count.
What this account does not establish
The results are the authors’ measurements, and this account did not reproduce them.
Isolation rests on correct allow lists, as the paper itself notes. A region granted by mistake is open to the function.
The verification covers the interpreter and the pre-flight checker. In the parts read, the paper does not extend it to the system calls, the hooks, the key-value stores or the installation path, which are ordinary operating system code.
The limits on instructions are an instruction budget §2.32, not a time limit. The time per instruction on a given processor and the time of every system call must be added before a deadline can be checked.
Permissions are coarse. The paper names as a limitation that each hook has one fixed set of permissions, so two tenants who need different permissions at the same event need two hooks, and hooks are fixed when the firmware is built.
The functions and the key-value stores of the measured system live in RAM. The parts read do not describe keeping them across a restart.
The isolation guarantee concerns memory and faults: a function cannot reach memory it was not granted. It says nothing about whether the function computes the right result, or about what a permitted system call does with the arguments it receives.
Questions answered
Why is a tiny function runtime different from a Linux container?
A tiny function runtime differs from a Linux container because it isolates one short function by checking each of its instructions in software, while a Linux container isolates a group of ordinary programs with the operating system kernel and the processor’s memory hardware. A Linux container is a set of processes, running programs, to which the Linux kernel gives separate namespaces, meaning their own view of process numbers, files, network interfaces and host name, and which it places in a cgroup §13.20 (control group) that limits processor time and memory. A tiny function runtime such as Femto-Containers (Zandberg and others, 2022) runs one small function, compiled to eBPF (extended Berkeley Packet Filter) bytecode, inside the operating system of a microcontroller. The two differ in six respects.
Unit of execution. A container runs whole programs, with their own files and libraries, for as long as they like. The function runs only when the event it is attached to occurs, returns a result to that point of the operating system, and is stopped if it exceeds a fixed limit on instructions.
Memory mediation. The processor’s memory management unit (MMU) keeps each container process inside its own address space, in hardware. A microcontroller usually has no MMU, so the interpreter checks every address the function uses against its stack and the memory regions granted to it.
Host calls. A container process calls the full Linux kernel through its system calls, restricted by the filters and privileges that the container software sets. The function may call only the few services that its attachment point grants.
Scheduling. The kernel interrupts container processes at any time and shares the processor among them. The function runs inside the code path that triggered it, so its running time adds to that path; the runtime bounds the number of instructions, not the time.
State between runs. A container keeps files in a file system. The function keeps values from one run to the next only in key-value stores that the host owns.
Fault containment. The kernel ends a faulty container process, and the other processes continue. A faulty function has its run aborted at the illegal access, and the operating system continues.
The difference cuts both ways. A small instruction set with checked memory accesses keeps the isolating code small enough to verify formally: the interpreter and checker of Femto-Containers are about 500 lines of C with a machine-checked proof. But the function gets none of the abstractions that an operating system gives a container, such as files, processes and network connections. Whatever it needs must be offered as a host service, and every such service lies outside that proof and must be checked on its own.
Related entries: Virtual machine (VM) (§2.3), Overflow-safe range check (§4.17), CertrBPF: connecting a VM specification to generated C (§21.3), Sandbox (§2.30), Software fault isolation (SFI) (§2.41), Instruction budget (fuel) (§2.32), Guest persistent state (§2.36), cgroup (§13.20), Memory management unit (MMU) (§6.9), Probe and hook (§14.26). Further reading: [206].