How to create memory in ptraced child process w/o child source code

How to create memory in ptraced child process w/o child source code

Post by Bill Che » Fri, 12 May 2000 04:00:00



I am trying to allocate a new segment of memory for the child process by way
of the controlling parent process under the ptrace environment.  The
underlying premise is that I do not want to change the child's source code
(assume source code is not available).

The following peudo code should give an idea of what I want to do.
main()
{
fork()

/* child */
ptrace(PTRACEME)
exec()  /* execute the real child */

/* parent */
wait()
create memory in child's process and write to it.
ptrace(DETACH)

Quote:}

If I can changed the child's source, I can do a shmget() and shmctl().
However, the child's source code is not available.

Can someone help?

 
 
 

How to create memory in ptraced child process w/o child source code

Post by Anand Krishnamoorth » Sat, 13 May 2000 04:00:00


I don't think that is ever possible... But one thing that beats me is why you
need such an operation to be performed... If the code in the child process
cannot know that a new page (say) of memory has been allocated to it, how is it
going to be useful to it other than it leaking memory??

Anand .K


Quote:> I am trying to allocate a new segment of memory for the child process by way
> of the controlling parent process under the ptrace environment.  The
> underlying premise is that I do not want to change the child's source code
> (assume source code is not available).

> The following peudo code should give an idea of what I want to do.
> main()
> {
> fork()

> /* child */
> ptrace(PTRACEME)
> exec()  /* execute the real child */

> /* parent */
> wait()
> create memory in child's process and write to it.
> ptrace(DETACH)

> }

> If I can changed the child's source, I can do a shmget() and shmctl().
> However, the child's source code is not available.

> Can someone help?


 
 
 

How to create memory in ptraced child process w/o child source code

Post by Mario Klebs » Sat, 13 May 2000 04:00:00



>I am trying to allocate a new segment of memory for the child process by way
>of the controlling parent process under the ptrace environment.  The
>underlying premise is that I do not want to change the child's source code
>(assume source code is not available).
>If I can changed the child's source, I can do a shmget() and shmctl().
>However, the child's source code is not available.

You could look into the source code of GDB. GDB is capable of
executing commands in the address space of the ptrace()d child. AFAIK,
GDB does put its code to execute somewhere on the stack of the target
process and executes it. But this does not work on systems, where the
stack pages do not have execute permissions (as on the Pyramid at my
university).

73, Mario
--

 
 
 

1. Getting a child and child's child process-id

 Why not just have the parent fork twice ??? Saves a lot of trouble ...
--


#  Have you read your Book In Basic Life Education today ? You should !!  #
#  Any views I express are not necessarily those of Brighton Polytechnic  #
###################### "surivorter erutangis a ma I" ######################

2. Slackware SCSI aborting due to timeout

3. Good PIM

4. smail failed to reap child process: No child processes

5. Okay, fairly easy... I think.

6. how to kill a child process that runs other children processes

7. Cisco TACACS+ for PPC

8. child process, child program

9. kill child and its all grad child processes?

10. how do i wait for child processes, and *their* children to finish

11. Capturing tracebacks from aborting child processes (ptrace?)

12. Can I ptrace(2) a non-child process ?