Questions tagged [mprotect]
88 questions
1
vote
0 answers
numa: next-touch policy
Can anyone explain how the "next-touch" policy can be implemented using "mprotect" on a NUMA system? Say I have an array of integers, A, I protect it using "mprotect". Next whenever any thread tries to access it i will only have information on the…

starter
- 325
- 1
- 5
- 15
1
vote
1 answer
memory mapped with mmap, and used with mprotect
I have to do a provide memory regions for threads and apply basic concepts of memory management. The idea is create a Thread Local Storage, and manage the with write, read, and clone, and erase. The problem is when I try to unprotect with mprotect…

gadiaz1
- 11
- 2
1
vote
1 answer
Detouring and using a _thiscall as a hook (GCC calling convention)
I've recently been working on detouring functions (only in Linux) and so far I've had great success. I was developing my own detouring class until I found this. I modernized the code a bit and converted it to C++ (as a class of course). That code is…

Elliott Darfink
- 1,153
- 14
- 34
0
votes
0 answers
Can I reallocate memory without change the address in C?
Can I reallocate memory without change the address in C?
I want to create a stack, and increase the size of it dynamically. I don't mind if the size must be multiple of page size. Is it possiple?
Or can I allocate multiple pages on different address…

mxmxlwlw
- 31
- 6
0
votes
0 answers
Query page protection under POSIX or linux
Is it possible to query the protections on a particular page? E.g. something like
void *page = mmap(NULL, 4096, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
assert(queryProtection(page) & PROT_READ);
assert(!(queryProtection(page) &…

asdfldsfdfjjfddjf
- 209
- 1
- 6
0
votes
0 answers
How to mprotect() existing address to enable PROT_WRITE without using mmap()? (is it even possible)?
#define base_address 0x00005555555551e7
I know that the literal base_addresscan be read and written but I can only do that using gdb, for example, if base_address is stored in rax
mov $0x00005555555551e7, %rax
mov (%rax), -0xc(%rbp)
mov -0xc(%rbp),…

user1094822
- 25
- 5
0
votes
1 answer
Is there any application that extensively uses `mprotect`?
I'm looking for an application for analysis purpose that puts pressure on mprotect. I found that JIT compilers use this syscall more than others. But almost all of them (e.g., JVM, Nodejs V8) cache the compiled code at first run resulting in…

Mohammad Siavashi
- 1,192
- 2
- 17
- 48
0
votes
0 answers
Using page protection to surface pointer/iterator invalidation bugs
Context: A container class we are writing does not guarantee pointer/iterator stability over a certain operation, because the operation has to reallocate in rare circumstances. The danger is that users inadvertently write code that assumes…

Max Langhof
- 23,383
- 5
- 39
- 72
0
votes
0 answers
calling mprotect in kernel module
I have a kernel module where I need to call mprotect for the current user process. I was thinking of making a direct call to do_mprotect_pkey but the function is marked as static. If not, is there any other way like going through a system call or…

ruke
- 55
- 5
0
votes
1 answer
Hijacking page fault handler
I have a process PID that access a memory region that it's not allowed to, the CPU creates a trap into the kernel which calls do_page_fault() which will send SIGSEGV to the user process. The user process has a custom signal handler that has some…

ruke
- 55
- 5
0
votes
1 answer
How to mprotect the data section?
I want to mprotect the data section. The following program will not run correctly. I understand the first argument of mprotect() should be aligned. But how to get an aligned memory address for the data section?
#include
#include…
user15502206
0
votes
1 answer
Most portable way to use mprotect() on allocated memory
I was wondering if there is a portable way to dynamically allocate memory and then restrict read/write access to a portion of this memory, e. g. using the POSIX function mprotect(). I can think of the following approaches:
Allocate memory using…

Socob
- 1,189
- 1
- 12
- 26
0
votes
3 answers
How can I force GDB to execute code for which there are no symbols
I have a C program that (for good reason) allocates memory, copies some code to it, uses mprotect() to give it execute privileges, and then calls that code.
Yes I know this is unportable and unsafe, but there's a good reason.
Anyway, I need to…

Badmanchild
- 990
- 9
- 18
0
votes
1 answer
assembly, how to use mprotect?
I am trying to make self modifying code in Linux. I thought it would works but didn't.
section .data
section .text
global _start
_start:
mov eax, 125 ;mprotect syscall number
mov ebx, _start ; *addr
mov ecx, 0x10000 ;page interval.
…

JaeIL Ryu
- 159
- 10
0
votes
3 answers
How to mprotect an object
My problem
I have a singleton whose memory is being corrupted by an unknown corruptor. Something is overwriting the memory for the singleton, and hundreds of bytes around it, with value 0. After the object is constructed via new, it is read-only for…

firebush
- 5,180
- 4
- 34
- 45