Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-24-2005, 10:01 AM
|
#1
|
LQ Newbie
Registered: Oct 2003
Posts: 18
Rep:
|
Memory Permissions For Executing Processes
Is it possible to change the access permissions for the memory where a currently executing process resides?
Am trying to write some self-modifying code and am failing because I get a page fault because apparently I'm not allowed to write to the processes memory area.
Cheers,
Tim
|
|
|
02-24-2005, 11:47 AM
|
#2
|
LQ Newbie
Registered: Nov 2004
Posts: 10
Rep:
|
Well, you shouldn't be able to do this, IN PRINCIPLE ! This is what multitasking and multi-user systems are all about.
It's a question of your code design: i f your code self-modifies itself (in user space), I do not see why you couldn't do that. But if your code calls system services and functions and tries to modify those (say, you're trying to write a virus maybe, or peek into other users' programs/data ..) then unless you defeat the security mechanisms of the OS you should not be able to do that !
|
|
|
02-24-2005, 11:59 AM
|
#3
|
LQ Newbie
Registered: Oct 2003
Posts: 18
Original Poster
Rep:
|
Cheers for the response.
It's the former rather than the later. I want to alter the memory where my code is - I actually want to change the code during execution. But is it not the case that during execution the code is no longer in user space, or am I misunderstanding something? As it stands I can look at the memory where my code resides, I can print it out, but any sort of modification causes a SIGFAULT.
I'm not entirely sure what you mean by multitasking or multi-user systems. Are you suggesting that the excuting process needs to spawn another process to modify itself?
|
|
|
02-24-2005, 01:40 PM
|
#4
|
LQ Newbie
Registered: Nov 2004
Posts: 10
Rep:
|
Well, I do not know- I never tried to profile a program that deep.
Since you want to self-modify the same process, it looks like a problem of the "chicken and egg".
SO, I guess the way out would be to use threads or some other mechanism that allows you to SHARE the process' memory. So, YES, somehow my instinct is that you have to somehow "freeze" the initial process, and while it is "numb", cut it open (that is, modify it). You could while doing this, "cut the tree branch under your feet" - something all the textbooks in CS bark at as a bad practice. But if you really know what you're doing, I guess it may be possible.
Plus, I guess the detailed implementation would wildly differ on different platforms- Solaris is slightly different than Linux, which slightly differs from BSD, etc, etc.
Can you look at some SMP code and try to guess from there what to do? What you'd like to do is kind of defeating the "synchronization" before a "critical region" in a parallel program. . .
Good luck, sorry not to be able to help you past the conceptual level..
|
|
|
All times are GMT -5. The time now is 04:42 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|