Section 17.22

Compare mechanisms using the same property

Question

How should a VM §2.3 sandbox §2.30, MPU §6.8 isolation, microkernel §19.5.4 separation, and native hotpatching §14.33 be compared?

Short answer

Compare a VM (virtual machine) sandbox, MPU (memory protection unit) isolation, microkernel separation and native hotpatching one property at a time, never by name. Fix one property, one threat or fault model §1.30 and one workload. For each mechanism, state which accesses it checks, which code must be correct for the property to hold, what it leaves unenforced, and what it costs, measured the same way for all four. Three mechanisms confine code; native hotpatching replaces code and confines nothing, so no single ranking exists.

Terms in the question

Full answer

The labels are not comparable. Each name stands for a mechanism with its own purpose. The VM sandbox, the MPU and the microkernel confine code: each limits the memory and the functions that one piece of code can reach. Native hotpatching changes the code of a running system and confines nothing. A sentence such as “a VM sandbox is safer than hotpatching” cannot be checked until “safer” is replaced by a property.

Step 1: fix the frame. Name three things before comparing anything.

Step 2: ask every mechanism the same four questions.

  1. Mediation: which accesses pass through a check? Complete mediation §1.16 means that every one does.

  2. Trusted computing base §1.4: which code and hardware must be correct for the property to hold? This set is the TCB (trusted computing base) for that property.

  3. Residue: what does the mechanism leave unenforced?

  4. Cost: processor time per event, code size, RAM, energy and the size of an update sent over the network, each counted the same way for all mechanisms.

Step 3: answer them for memory confinement.

Step 4: read the table with care.

Worked example

Property: the code of an update may write only its own data object of 200 bytes. Compare the VM sandbox and MPU isolation for exactly this property.

VM sandbox. The object starts at address 0x20000100. Its last byte is at that address plus 199, which is 0x200001C7, because 199 is 0xC7 in hexadecimal. The bounds check allows exactly these 200 bytes and nothing more.

MPU of the Armv7-M architecture, which the optional MPU of the Cortex-M4 §6.3 processor implements with 8 regions. The size of each region must be a power of two of at least 32 bytes, and its start address must be a multiple of its size.

  1. The smallest power of two not below 200 is 256, because 128<200≤256128 < 200 \le 256.

  2. The start address 0x20000100 is a multiple of 256, which is 0x100, so a 256-byte region can start there. It covers 0x20000100 to 0x200001FF.

  3. The region grants 256−200=56256 - 200 = 56 bytes beyond the object, from 0x200001C8 to 0x200001FF. If another variable lies there, the update can change it without any fault.

Now move the object to 0x20000140. Its last byte is 0x20000207. The 256-byte region at 0x20000100 ends at 0x200001FF and misses the last 8 bytes. A 512-byte region must start at a multiple of 512, here 0x20000000 or 0x20000200, and neither covers both ends of the object. The smallest region that fits is 1,024 bytes at 0x20000000, which grants 1024−200=8241024 - 200 = 824 bytes too many. Armv7-M also lets a region of 256 bytes or more switch off any of its 8 equal sub-regions. That leaves 7 sub-regions of 32 bytes, 7×32=2247 \times 32 = 224 bytes, in the first placement, and 3 sub-regions of 128 bytes, 3×128=3843 \times 128 = 384 bytes, in the second: still 224−200=24224 - 200 = 24 and 384−200=184384 - 200 = 184 bytes too many. The usual repair is to pad the object to a power of two and place it at a multiple of that size, which spends memory.

Microkernel separation on the same microcontroller enforces its boundaries with the same MPU, so it has the same granularity. Native hotpatching with no MPU configured lets the patched code write every byte the program can write. For the VM sandbox, the MPU and native hotpatching, the writable memory beyond the object is therefore 0 bytes, 24 to 824 bytes depending on placement and on the use of sub-regions, and unlimited. On processor time per access the order reverses: native code runs without any check, the MPU check adds no instructions, and the bounds check adds instructions to every access. Neither order is the ranking; each answers one question.

Follow-up questions and limits

Does a smaller TCB make a mechanism better? Only for the same property, and only if the smaller TCB is in fact correct. A small kernel says nothing about a timing property that depends on drivers outside it.

Can a feature table show that a mechanism is new or superior? No. A table organizes evidence about the systems in it. It cannot show that no other system has the property, and it says nothing about performance unless the costs were measured on the same workload with the same accounting.

What about a property that the comparison did not fix? Answer the four questions again for that property. The ranking may change, as the example shows for memory confinement and processor time.

This answer does not cover the internal design of each mechanism, or the many variants within each family, such as hotpatching tools that check a patch before applying it.

Fullest treatment: Security claim scope (§1.45).

Related entries: Trusted computing base (TCB) (§1.4), Sandbox (§2.30), Memory protection unit (MPU) (§6.8), Refinement (§3.32), Microkernel, monolithic kernel, and service isolation (§19.5.4), Dynamic patching and hot update (§14.33), Complete mediation (§1.16), Memory management unit (MMU) (§6.9). Further reading: [156, 174].