Questions tagged [mprotect]
88 questions
0
votes
1 answer
10.13 High Sierra OSX - Python mprotect always fails when granting exec permission, with ENOMEM
Background:
Writing a proof of concept that involves executing machine code within a python program. To do this on osx so I had to utilize ctypes and libc.dylib and the following function calls:
(With SIP disabled)
valloc to allocate aligned…

0x5929
- 400
- 1
- 4
- 16
0
votes
0 answers
Calling mprotect on dynamically allocated memory results in error with error code EACCES
After hearing about it in a C course I've been experimenting with self-modifying code. I have a function which sets the memory protections for a segment of memory using mprotect:
int SetMemoryProtections(void* addr, size_t length, int…

Alecto Irene Perez
- 10,321
- 23
- 46
0
votes
1 answer
Is it possible to call sys_mprotect from a kernel module
I'm writing a kernel module that needs to change page permissions for a task. Normally, the task would just call mprotect and set the permissions. As I understand Linux kernel has sys_mprotect, which performs the actual system call.
Is it possible…

hsnm
- 658
- 1
- 8
- 20
0
votes
1 answer
mprotect() Invalid argument in C
I want to allocate 4096 Bytes with posix_memalign in the array "page", and then protect it with PROT_NONE via mprotect().
The allocation seems to work, but protect() returns 1 instead of 0. The given error code is "Invalid argument".
I think it's…

J. Doe
- 3
- 2
0
votes
2 answers
Which anonymous areas are created/accessed by libc?
Is there a way to find out which anonymous Virtual Memory Areas are created/accessed by libc?
I have a program that mprotects VMAs on its address space.
But when it mprotects an area that will be accessed by libc, a SIGSEGV occurs. Unfortunately,…

Paschalis
- 11,929
- 9
- 52
- 82
0
votes
1 answer
Calculate align page of an address statically
i need to calculate statically the address of the first page that contains the text segment of an elf, in order to use mprotect() and make the text segment writable.
Section Headers:
[Nr] Name Type Addr Off Size ES…

Cronovirus
- 187
- 1
- 9
0
votes
1 answer
mprotect and file handles
I have this simple program where I am trying to protect a block of memory, and then read a file into that memory, releasing it when it segfaults..
first I thought there was only a problem if the file is a fifo.. but now it seems that even for a…

Alon
- 1,776
- 13
- 31
0
votes
0 answers
mprotect failing to recover from fifo write/read interrupt inside the fread?
I have a simple procedure that contains 2 processes that write and read from a fifo.
I wanted to add mprotect on the buffer that the reader reads to, and then "release" it(add PROT_WRITE | READ) when there is an interrupt on it.
it seems that if I…

Alon
- 1,776
- 13
- 31
0
votes
0 answers
Enabling mprotect does not return to normal state?
I am trying to create a program to track memory of a process..
What I have is at a certain point trying to protect all memory using my protect function:
static void Protect(void* ptr, size_t size)
{
MemoryMgr& mgr =…

Alon
- 1,776
- 13
- 31
0
votes
0 answers
How to speed up set_tls and mprotect on ARM application start?
I'm using an ARM (TI814x) on NAND (UbiFS). When starting an QtGui application it takes about 1 second until set_tls (thread local storage?) and mprotect is done (while loading all shared libraries takes 1.3 seconds).
Why does it take so long and is…

Charly
- 1,270
- 19
- 42
0
votes
1 answer
mprotect: how to get the instruction which causes protection violation?
I am using mprotect to set some memory pages as write protected. When any writing is tried in that memory region, the program gets a SIGSEGV signal. From the signal handler I know in which memory address the write was tried, but I don't know the way…

Muhammad Razib
- 1,297
- 9
- 13
0
votes
1 answer
How to constrain malloc to a specific region of memory
Is there anything that:
Allocates/deallocates/reallocates many variable sized objects without fragmentation (basically what malloc does) and
keeps track of all memory pages used in for these allocations so that I can
later mprotect all of these…

Ramon
- 8,202
- 4
- 33
- 41
0
votes
1 answer
C Programming: Protected memory across fork()
I need to protect the pages in a parent from the pages in a child
I have tried not using shm_open with the MAP_ANONYMOUS flag and fd = -1 in mmap.
I have tried protecting the underlying memory with fchmod.
I currently am utilizing the following…

Tabgok
- 7
- 1