Executable memory allocator with support for dual mapping and W^X protection

Overview

jit-allocator

A simple memory allocator for executable code. Use JitAllocator type to allocate/release memory and virtual_memory module functions to enable proper access for executable code. So if you want to allocate a new code to execute it is usually done like this:

use jit_allocator::*;
let compiled_code = ...;
let compiled_code_size = ...;

let mut jit_allocator = JitAllocator::new(Default::default());
let (rx, rw) = jit_allocator.alloc(size)?;

protect_jit_memory(ProtectJitAccess::ReadWrite); // allows to write to RWX code in current thread,
                                                 // it is no-op on all platforms except macOS AArch64
unsafe { copy_nonoverlapping(compiled_code, rw, compiled_code_size);  }
protect_jit_memory(ProtectJitAccess::ReadExecute); // disables writes to RWX code in current thread, 
                                                   // it is no-op on all platforms except macOS AArch64
flush_instruction_cache(rx, compiled_code_size); // flush icache, not required on x86-64 
                                                 // but required on other platforms due 
                                                 // to lack of coherent dcache/icache.

// When you're done with your machine code you can release it:
unsafe { 
    jit_allocator.release(rx)?;
}
You might also like...
Hide memory artifacts using ROP and hardware breakpoints.
Hide memory artifacts using ROP and hardware breakpoints.

Description This tool is a simple PoC of how to hide memory artifacts using a ROP chain in combination with hardware breakpoints. The ROP chain will c

Use enum to predicate something, support | and & operator.
Use enum to predicate something, support | and & operator.

Predicate Use enum to predicate something. Just need to implement Predicate Trait with predicate-macros crate, support | and & operator. Don't impleme

RustSBI support on SiFive FU740 board; FU740 is a five-core heterogeneous processor with four SiFive U74 cores, and one SiFive S7 core

RustSBI 在 HiFive Unmatched 主板的支持软件 这个项目的目的是在SiFive HiFive Unmatched主板上支持RustSBI。 RustSBI是一个引导程序环境;主板上电时,RustSBI将会先行启动,而后,它将会找到一个可引导的操作系统,引导启动这个操作系统。 在

Meet Rustacean GPT, an experimental project transforming OpenAi's GPT into a helpful, autonomous software engineer to support senior developers and simplify coding life! 🚀🤖🧠
Meet Rustacean GPT, an experimental project transforming OpenAi's GPT into a helpful, autonomous software engineer to support senior developers and simplify coding life! 🚀🤖🧠

Rustacean GPT Welcome, fellow coding enthusiasts! 🚀 🤖 I am excited to introduce you to Rustacean GPT, my humble yet ambitious project that aims to t

Traits for inspecting memory usage of Rust types

memuse This crate contains traits for measuring the dynamic memory usage of Rust types. About Memory-tracking is a common activity in large applicatio

secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process.

secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process. More specifically, the crate disables core dumps and tries to disable tracing on unix-like OSes.

Allocate memory at compile time!

const-alloc Link to the docs! Allocate memory at compile time! Currently, in stable rust there is no way to dynamically allocate or deallocate memory

Memory.lol - a tiny web service that provides historical information about social media accounts

memory.lol Overview This project is a tiny web service that provides historical information about social media accounts. It can currently be used to l

Simple library to host lv2 plugins. Is not meant to support any kind of GUI.

lv2-host-minimal Simple library to host lv2 plugins. Is not meant to support any kind of GUI. Host fx plugins (audio in, audio out) Set parameters Hos

Owner
playX
Real name: Adel Prokurov. Rust programmer. Love doing compiler and VM related development. :) Languages: Russian, English.
playX
Fast, concurrent, arena-based allocator with drop support

blink-alloc Blink-alloc is extremely fast allocator based on the common idea of allocating linearly zipping a cursor through memory chunk and reset ev

Zakarum 55 Mar 5, 2023
IITC-CE Telegram Chat Spam Protection

ADA AntiBot This bot bans spammers in Telegram chat. Run To run you should export environment variables: TELOXIDE_TOKEN - telegram bot token TELEGRAM_

Ingress Intel Total Conversion — Community Edition 4 May 23, 2022
A rust wrapper for the spam protection API

SpamProtection-rs Table of contents About Supported Rust version Features How to use Credits License About This repo has been shifted to the official

cyberknight777 28 Aug 5, 2022
Reverse engineering Vercel's bot protection

vercel-anti-bot Reverse engineering and analysis of Vercel's bot protection used on https://sdk.vercel.ai (and potentially more of their platforms). U

Levi 16 Aug 22, 2023
global allocator that provides hooks for tracking allocation events

tracking-allocator A GlobalAlloc-compatible allocator implementation that provides the ability to track allocation events. examples As allocators are

Toby Lawrence 39 Dec 22, 2022
The Solid-State Register Allocator

The Solid-State Register Allocator A simple, extremely fast, reverse linear scan register allocator. See the detailed write-up for an in-depth explana

Matt Keeter 66 Dec 13, 2022
ttasm is an assembler for assembling source code to TTVM executable.

ttasm is an assembler for assembling source code to TTVM executable.

maDeveloper 1 Nov 8, 2021
Auto launch any application or executable at startup

Auto Launch Auto launch any application or executable at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux. How does it work

GyDi 38 Dec 27, 2022
Symbolically Executable Stack Machines in Rust

Symbolically Executable Stack Machines in Rust Symbolic Stack Machines is a library for implementing symbolically executable stack-based virtual machi

TannrA 64 Dec 28, 2022
🦀🚀🔥 A blazingly fast and memory-efficient implementation of `if err != nil` 🔥🚀🦀

?????? A blazingly fast and memory-efficient implementation of `if err != nil` ??????

Federico Damián Schonborn 6 Dec 30, 2022