A Formal Model of Checked C

01/31/2022
by   Liyi Li, et al.
0

We present a formal model of Checked C, a dialect of C that aims to enforce spatial memory safety. Our model pays particular attention to the semantics of dynamically sized, potentially null-terminated arrays. We formalize this model in Coq, and prove that any spatial memory safety errors can be blamed on portions of the program labeled unchecked; this is a Checked C feature that supports incremental porting and backward compatibility. While our model's operational semantics uses annotated ("fat") pointers to enforce spatial safety, we show that such annotations can be safely erased: Using PLT Redex we formalize an executable version of our model and a compilation procedure from it to an untyped C-like language, and use randomized testing to validate that generated code faithfully simulates the original. Finally, we develop a custom random generator for well-typed and almost-well-typed terms in our Redex model, and use it to search for inconsistencies between our model and the Clang Checked C implementation. We find these steps to be a useful way to co-develop a language (Checked C is still in development) and a core model of it.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
04/17/2018

K-Rust: An Executable Formal Semantics for Rust

Rust is a system programming language designed for providing better memo...
research
10/26/2020

Taming x86-TSO Persistency (Extended Version)

We study the formal semantics of non-volatile memory in the x86-TSO arch...
research
02/03/2023

CheckedCBox: Type Directed Program Partitioning with Checked C for Incremental Spatial Memory Safety

Spatial memory safety violation is still a major issue for C programs. C...
research
06/07/2017

Decoding Lua: Formal Semantics for the Developer and the Semanticist

We provide formal semantics for a large subset of the Lua programming la...
research
05/20/2017

The Meaning of Memory Safety

We propose a rigorous characterization of what it means for a programmin...
research
11/21/2022

Formal Abstractions for Packet Scheduling

This paper studies PIFO trees from a programming language perspective. P...

Please sign up or login with your details

Forgot password? Click here to reset