Skip to content

dmp-mitigation/dmp-rt

Repository files navigation

dmp-rt

dmp-rt is a low-level memory management utility library.
It provides custom secure dynamic memory allocation (smalloc), manipulation routines, and proxy-wrapped syscalls for mitigating data at rest side channels created by data memory prefetchers.


Key Features

  • Custom Secure Memory Allocator (smalloc):
    Implements a custom memory allocation system designed to support secret and non-secret data separation using memory tagging (via special bit flags on addresses).
  • Balanced Binary Tree Management:
    Manages address ranges and allocations via an AVL/tree-like data structure for fast lookup, insertion, and removal.
  • Stack and Heap Mapping:
    Supports proxy structures to track and isolate stack frames and global/heap allocations.
  • Shadow Memory Utilities:
    Tools to transform, mask, or proxy pointer addresses and to determine whether a pointer refers to a "secret" region.
  • Safe libc Replacements (slibc):
    Reimplements standard libc memory and string routines (like memcpy, memset, strcpy) with boundary checks, extra zeroization for secret data, and integration with the smalloc memory system.
  • Proxy System Calls:
    Wrapped system calls capable of operating on secret/proxied memory (e.g., poll, open, getrandom).

Structure

  • smalloc.c / smalloc.cpp: Core memory allocator and address manipulation logic.
  • smalloc.h, smalloc-c.h, smalloc-cpp.h: Type and API declarations.
  • smalloc-vector.cpp: Vector-based alternate implementation of address management.
  • slibc/: Secure libc-like routines and syscall wrappers.

Build from Source

Standard build:

git clone https://github.com/dmp-mitigation/dmp-rt.git
cd dmp-rt
make -B all 

The build system supports both C and C++ implementations. Use targets like compile-c, compile-cpp, and slibc if you want finer control.

Manual (for quick testing, e.g., just the allocator):

gcc -c -g -fPIC smalloc.c -I./ -o smalloc.o
gcc -shared -g smalloc.o -o libsmalloc.so

Additional compilation scripts and Makefiles are present for slibc and other modules.


Usage

Include the headers from this repository (e.g., smalloc.h, smalloc-cpp.h) in your project or link against the generated libsmalloc.so.

Examples of using the custom allocator and AVL tree:

#include <smalloc.h>
struct smalloc__root* tree = smalloc__create_tree();
tree->_root = smalloc__insert_node(tree->_root, 42, 20);
// ... lookup, delete, etc.

See test_tree.c and test_tree1.c for more in-depth usage.


Contributing

Contributions are welcome for improved features, bug fixes, or new memory management tools. Please use issues or pull requests for discussion.


Support

For questions, feature requests, or to report bugs, please open an issue on GitHub.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors