This chapter explains how a system can run a small program supplied by someone else without letting that program harm it. Its running example is eBPF §2.1, an instruction set for small programs that a host, such as an operating-system kernel or the firmware of a device, loads and runs while it is already running. The first entries describe the program format: what a virtual machine §2.3 and its bytecode §2.4 are, how eBPF’s registers and instructions are encoded, and the ways to execute bytecode, by an interpreter §2.13 or by translating it into machine code before or while it runs.
The rest of the chapter is about confinement. A guest program can reach the host only through helper functions §2.19 and the data that the host hands it, so the chapter defines the contracts of these interfaces, the memory a guest may use, and the checks that keep it inside: checks before a program is admitted, bounds checks while it runs, and a limit on the number of instructions it may execute. It closes with what these checks do and do not establish, such as spatial and temporal memory safety §2.29, termination, determinism and the difference between knowing who wrote a program and knowing that it is safe to run, and with alternatives such as software fault isolation §2.41 and proof-carrying code §2.42. The chapters on memory and on program analysis supply useful background.