KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to allocate a memory with execute permissions. So I use mprotect to change the permissions.. To get a page aligned memory I use a valloc function. void * temp = (void *) valloc(x); and then if( mprotect(temp, BLOCK_SIZE, (PROT_READ | PROT_WRITE |PROT_EXEC))) { exit(-1); } Now I want to add more memory to this allocated block. Hence I use a realloc function. void * new_temp = (void *) realloc(temp, 1024); Will this reallocate automatically change the permissions of the allocated memory to the ones I had set earlier ?? In case realloc moves the entire block to a different location, what be the permissions of allocated memory earlier and the newly allocated memory? Should mprotect be used again to get execute permissions memory. And is there a API to realloc on page size boundary like valloc . ?
Tags (comma-separated)
Save Edits
Cancel