https://github.com/kizzycode/ma_proper
This crate provides the cleaning memory allocator `MAProper`
https://github.com/kizzycode/ma_proper
memory-allocation memory-allocator memory-management security
Last synced: about 2 months ago
JSON representation
This crate provides the cleaning memory allocator `MAProper`
- Host: GitHub
- URL: https://github.com/kizzycode/ma_proper
- Owner: KizzyCode
- Created: 2019-01-20T22:19:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-15T00:47:41.000Z (over 3 years ago)
- Last Synced: 2025-03-07T16:19:22.999Z (2 months ago)
- Topics: memory-allocation, memory-allocator, memory-management, security
- Language: Rust
- Size: 37.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE BSD 2-CLAUSE.md
Awesome Lists containing this project
README
[](https://opensource.org/licenses/BSD-2-Clause)
[](https://opensource.org/licenses/MIT)
[](https://docs.rs/ma_proper)
[](https://crates.io/crates/ma_proper)
[](https://crates.io/crates/ma_proper)
[](https://deps.rs/crate/ma_proper/1.0.0)
[](https://travis-ci.org/KizzyCode/ma_proper)
[](https://ci.appveyor.com/project/KizzyCode/ma-proper)# MAProper
This crate provides the securely overwriting memory allocator `MAProper` ๐งน## What is `MAProper`
`MAProper` is an extension around `std::alloc::System` which ensures that the allocated memory is
always erased before it is deallocated by using one of
`memset_s`/`SecureZeroMemory`/`explicit_bzero`/`explicit_memset`.## Whats the purpose of `MAProper`
`MAProper` becomes handy if you're dealing with a lot of sensitive data: because the memory
management of dynamically allocating types like `Vec` or `String` is opaque, you basically have no
real chance to reliably trace and erase their sensitive contents.However they all use the global allocator โ so all ways lead to Rome (or in this case to the global
allocator's `alloc` and `dealloc` functions) โ which is where `MAProper` is sitting and waiting to
take care of the discarded memory.## Using `MAProper` as global allocator (example)
```rust
#[global_allocator]
static MA_PROPER: ma_proper::MAProper = ma_proper::MAProper;fn main() {
// This `Vec` will allocate memory through `MA_PROPER` above
let mut v = Vec::new();
v.push(1);
}
```## Important
Please note that `MAProper` only erases memory that is deallocated properly. This especially means
that:
- stack items are __not erased__ by this allocator โ to erase stack memory, we expose
`MAProper::erase_slice` and `MAProper::erase_ptr` so that you can erase them manually if
necessary
- depending on your panic-policy and your `Rc`/`Arc` use (retain-cycles), the destructor (and thus
the deallocator) may never be called