LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 05-04-2005, 08:08 AM   #1
tim_l
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?

Tim
 
Old 05-04-2005, 08:12 AM   #2
jtshaw
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.
 
  


Reply



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 10:14 AM
mprotect() return codes tim_l Programming 2 05-09-2005 07:38 AM
Call to mprotect() tim_l Linux - General 1 05-03-2005 09:44 AM
mprotect Damaged Soul Programming 0 11-28-2004 05:18 AM
What is SIGSEGV? zombie_geek Linux - Newbie 2 02-03-2004 07:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:51 AM.

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