Welcome to the Linux Foundation Forum!

Add a flag to hook mmap

Posts: 4

Sometimes, mmap is used specifically for memory allocation, but directly hooking mmap can lead to many issues. To handle this more effectively, we could assign a flag to indicate when mmap is being used for allocation purposes. By using this flag, we could dynamically adjust how we hook or bypass mmap based on the allocation context.

Such as:
#define MAP_HOOK 1 << 30
m_alloc_mem = mmap(nullptr, TOT_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HOOK, -1, 0);

I believe this is a feasible approach.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training