The CHERI C/C++ Programming Guide provides an overview of the differences between C compiled to traditional architectures and C compiled to architectures supporting CHERI. We hope that it is of utility as the experiment spreads beyond the Computer Laboratory here at the University of Cambridge.

The document is available via the CL’s library at https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-947.html or locally.

Abstract:

This document is a brief introduction to the CHERI C/C++ programming languages. We explain the principles underlying these language variants, and their grounding in CHERI’s multiple architectural instantiations: CHERI-MIPS, CHERI-RISC-V, and Arm’s Morello. We describe the most commonly encountered differences between these dialects and C/C++ on conventional architectures, and where existing software may require minor changes. We document new compiler warnings and errors that may be experienced compiling code with the CHERI Clang/LLVM compiler, and suggest how they may be addressed through typically minor source-code changes. We explain how modest language extensions allow selected software, such as memory allocators, to further refine permissions and bounds on pointers. This guidance is based on our experience adapting the FreeBSD operating-system userspace, and applications such as PostgreSQL and WebKit, to run in a CHERI C/C++ capability-based programming environment. We conclude by recommending further reading.

BibTeX:

@TechReport{watson:chericprog,
  author  = {Watson, Robert N. M. and Richardson, Alexander and Davis, Brooks
            and Baldwin, John and Chisnall, David and Clarke, Jessica and
            Filardo, Nathaniel and Moore, Simon W. and Napierala, Edward and
            Sewell, Peter and Neumann, Peter G.},
  title   = {{CHERI C/C++ Programming Guide}},
  year    = {2020},
  month   = {jun},
  url     = {https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-947.pdf},
  institution={University of Cambridge, Computer Laboratory},
  number  = {UCAM-CL-TR-947}
}