Skip to content

Temporal safety is required #6

@stephenrkell

Description

@stephenrkell

This issue collects thoughts about how to provide temporal safety in libcrunch.

One idea is to start with a quarantining malloc. Wes has a version of dlmalloc that we could perhaps use for this.

The basic idea is that a "free" event causes memory to be quarantined, but it is not reused until it is known to have no live inbound pointers. This already trades away some bug-finding power (those live pointers may still be used, albeit illegally), but seems a good trade and it preserves a sensible notion of safety.

The "no live inbound pointers" is the hard part. The most obvious way is to use vaguely GC-like sweep techniques.

What about custom allocators? Want there to be a "quarantine protocol" supported by liballocs. An allocator that follows this guarantees not to re-use memory that the system has not attested is no longer reachable. That means the sweep can be written at the liballocs level. Also raises my often-mooted idea of tracking both over- and under-approximations of reachability at the bigalloc level.

Unlike the CHERI work, we probably need the sweep to proceed allocationwise, rather than by page and cacheline. Need to remind myself exactly how this works. How was the "does this point to quarantine?" test done? Brief answer: a per-page quarantine bitmap, one bit per word.

Also, the usual tricks: can use mprotect if there will be no or likely-few valid use of page-overlapping objects. Use of this trick lets us decouple virtual address reuse from physical memory reuse. Use of virtual address rotation lets us reduce the frequency of page-overlapping objects. These are all "per-allocator" tricks, but maybe some plumbing in liballocs would help, e.g. to convert segfaults into allocator upcalls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions