execve() and more memory related questions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
spix
Member
Member
Posts: 128
Joined: Mon Jun 26, 2006 8:41 am
Location: Millicent, South Australia
Contact:

execve() and more memory related questions

Post by spix »

Hi all

I've been tinkering with my execve() syscall, and have a couple of questions..

in the man page for execve() it says that all the text data and bss are over written with the new task's image, but what about the memory that has been allocated dynamically?

I assumed that execve would require a freshly cleaned address space for the new program, and went about programming such a function and couldn't get it to work.

Thinking about it, is clearing the memory really an issue? If I reset the current "memory allocated" thing to 0, the allocater will just allocate pages again, and if it has stuff in it, well clearing that is the job of the program (or allocater)?

Am I right in thinking that I only need to clear the memory when the task is finished?
proxy

Re:execve() and more memory related questions

Post by proxy »

I suppose the real issue is data leakage, if you don't clear things out, a child process could hypothetically read sensitive data from the parent process since it could through some pointer trickery access these uncleared pages.

proxy
JoeKayzA

Re:execve() and more memory related questions

Post by JoeKayzA »

spix wrote: Thinking about it, is clearing the memory really an issue? If I reset the current "memory allocated" thing to 0, the allocater will just allocate pages again, and if it has stuff in it, well clearing that is the job of the program (or allocater)?
I would say it's the allocator's job to return all allocated pages back to the kernel, or, at least, signal the kernel that it can now take back all the memory (the latter would be neccessary anyway if you want to clean up after a crashing process). Of course it depends on your design as well.

cheers Joe
Post Reply