An implementation of C abstract machine that can run legacy C code with Strong memory protection guarantees.
References:
Beyond the PDP-11: Architectural support for a memory-safe C abstract machine. 2015, ASPLOS. paper, slides
ISO/IEC 9899:2011 Information technology – Programming languages – C. link
Is address space 1 reserved? LLVMdev, 2015. link
CheriABI: Enforcing Valide Pointer Provenance and Minimizinig Pointer Privilege in the POSIX C Run-time Environment, ASPLOS, 2019.
Into the depths of C: elaborating the de facto standards. ACM SIGPLAN Notices, 51(6), pp.1-15. 2016. pdf
Exploring C Semantics and Pointer Provenance, POPL, 2019.
Pure-capability enabled for zlib
, but still need the pragma
changes to keep compatable with MIPS ABI.
pragma
do?pragma
, or we will eliminate all the pragma
?idioms
, is it possible to change the Compiler to converting those unsafe
idioms into a safe
one in the older CHERI ISA?malloc
, kernel’s context switching, signal handler dispatching, I/O memory, MMU, etc.Tracking all the pointer->integer->pointer flows. Make the collector accurate first. Then find a way to optimize it.
Use SAFECode Strategy for a quoted safe.
Original Fat Pointers:
Capabilities:
malloc()
is outside of the abstract machine.malloc()
.malloc()
is an object. And it is undefined behavior to use it after calling free()
.malloc()
is not yet part of the C abstract machine.mmap()
or brk()
, which deals with pages of memory.If the member used to read the contents of a union object is not the same as the member last used to store a value in the object, the appropriate part of the object representation of the value is reinterpreted as an object representation in the new type… This might be a trap representation.
This requirement is useful for low-level contexts: it is possbile to subvert the type system and interpret memory as differnet formats.
void *dlsym(...)
function, used to look up a symbol in a shared library.dlsym
, and is not defined behaviour in C.memchr
in C specification, takes a const
-qualified pointer as the first argument, and returns a non-const
pointer derived from it.pointer -> integer -> pointer. e.g. xor
linked list:
each node has a pointer that is the address of the previous node xor
’d with the address of the next node, allowing traversal in both directions.
unused bits in a pointer used to store information.
It is not possible to implement a copying or relocating garbage collector if it is possible for object addresses to escape from the collector.
Efficient implementation of full temporal safety will have unexpected behavior for much existing code.
Refine CHERI to meet C Abstract model.
Examples:
v1 -> v2 : prevent integer loaded into capability registers -> allow propagation of tags.
memcpy()
does not need to aware the existence of pointers in the copied data.unions
too.v2 -> v3: add ‘fat pointers’ style, an offset
.
supporting arbitrary pointer arithmetic and comparison: CPrtCmp
allow more permission fields
additional hw checks, such as GC, info-flow tracking, integrity in concurrency, etc.
const
by removing the store
permission. __input
and __output
to discard permissions.
CToPtr
and CFromPtr
__capability
qualifier for hybrid compilation mode.
v3 supports storing data in unused bit of a pointer (must in bound)
Function Pointers as Capability
CJALR
(capability jump and link register), such that when a function is executing, it is impossible to jump out of it without an explicit call.A relocating generational garbage collector.
offset
, a pointer addition decreases the range.offset
, etc.100MHz Stratix IV FPGA. DDR DRAM is faster then CPU, so cache misses are less costly.
Code Changes
Annotation are manually added to understand their placement. But compiler can represent pointers using capalibities internally, avoiding the need for manual annotations.
Semantic Changes:
Compiler support:
zlib
version 1: header annotation for compatability with MIPS ABI. A single pragma at the start and end of the library header.zlib
version 2: copying structures when they are passed across the library boundary.
If you could revise
the fundmental principles of
computer system design
to improve security...
... what would you change?