Prerequisite: gef with CHERI support
# assuming this directory is named gef-plugins
echo gef config gef.extra_plugins_dir /path/to/gef-plugins >> ~/.gdbinit
-
Jemalloc heap manager: identify the heap memory regions, visualize heap allocations with metadata. Note that it is only tested on CheriBSD jemalloc.
jheap chunk <address>
: inspect a heap allocationjheap chunks
: list in use heap allocationsjheap uaf [noheap]
: scan for freed heap allocations that are pointed by valid capabilities in memory. Optionally, exclude capabilities stored in the heap.
-
Snmalloc heap manager: tested on https://github.com/microsoft/snmalloc
snheap info
: print pagemap addresssnheap localcache
: list entries in local cacheLocalCache
(also called small fast free lists)snheap slabs
: lists slabs in the core allocator (there can be multiple slabs per small size class, and large slabs)snheap remote
: lists the remote deallocation queue of the current of given thread(s)snheap freelists
: list entries in local cacheLocalCache
in the local allocator, the deallocation queue in remote allocators and active slab free lists in the core allocatorsnheap chunk <address>
: lists details about theAlloc
and its slab. If the metaentry has theREMOTE_BACKEND_MARKER
bit asserted, that is, the chunk is owned by the backend (notAlloc
-bounded), then indicate it as aChunk
. Because backend chunks' metaentry are parsed differently depending on the specificRange
, we can make a best guess of the owningRange
. In the case that CHERI revocation is enabled, also print whether it is quarantined and its revocation bit value.
-
Quarantine heap manager:
mrs info
: display general information about the mrs quarantine, global state and the revocation bitmap.mrs chunk <address>
: query whether this chunk is owned by the allocator or quarantined. Also show shadow bitmap offset and value. The information we can query is limited because the capability load generation counter registers are not available to gdb in ring 3, so we can't inspect the kernel internal state of caprevoke unless debugging the kernel or using qemu.mrs quarantine
: print the quarantined chunks (and their shadow bit values of the allocation first word).
- More Jemalloc heap commands, like
arena(s)
,extent(s)
,tcache
,slab(s)
- PartitionAlloc
- Snmalloc:
- Identify heap mappings in
vmmap
output (test with snmalloc as libc malloc) snheap chunks
: list allocatedChunk
s by parsing the metaentries in pagemap that correspond to chunks returned by the backend. The pipe of Ranges returnArena
-bounded pointers, and the backend casts object allocation pointers toChunk
-bounded pointers and metadata pointers to the correspondingSlabMetadata
pointer.snheap smallbuddy
: display world view of the chunks owned by the small buddy range in the backendsnheap largebuddy
: display world view of the chunks owned by the large buddy range in the backend
- Identify heap mappings in
- Refactor: group jemalloc and snmalloc as heap manager options and override
gef.heap
.