Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-04-2005, 09:08 AM   #1
LQ Newbie
Registered: Oct 2003
Posts: 18

Rep: Reputation: 0
mprotect and SIGSEGV

I'm working on a program which needs to alter the access rights of the memory that the executable isloaded into.

So at runtime the program finds the addresses of the area of memory it wants to change (within the executable), sets it to a page boundary and then calls mprotect with PROT_READ | PROT_WRITE | PROT_EXEC. This seems fine in all of the cases I've tried it, mprotect doesn't ever seem to fail and everything seems hunky-dork.

However, in some cases, if I then come to try and alter the memory I've set the permissions for, I get a signal 11 SIGSEGV. And I'm confused. Surely if I couldn't set the access rights mprotect would fail? And if mprotect doesn't fail, how come I can't change the memory which I've set to PROT_WRITE?

Old 05-04-2005, 09:12 AM   #2
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SIGSEGV everywhere !!! nolimitz Linux - Software 3 08-12-2005 11:14 AM
mprotect() return codes tim_l Programming 2 05-09-2005 08:38 AM
Call to mprotect() tim_l Linux - General 1 05-03-2005 10:44 AM
mprotect Damaged Soul Programming 0 11-28-2004 06:18 AM
What is SIGSEGV? zombie_geek Linux - Newbie 2 02-03-2004 08:33 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:21 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration