2

Linux Kernel version 3.2 and further have a capability called cross memory attach.

Here is the link to it. I was not able to get a lot of help in that regard. http://man7.org/linux/man-pages/man2/process_vm_readv.2.html

In the syntax we need the address of the remote memory where we want to write to or read from. My question is how do I get the address of this remote memory if I am using fork().

Suppose I am sending something from parent process to child process using cross memory attach. How do I send the address of the remote memory to the parent process from the child process?

patro
  • 111
  • 2
  • 10
  • You could use a standard `pipe(2)` or get the mappings from `/proc/pid/maps` – Sergey L. Jun 26 '13 at 15:52
  • can i send a pointer using pipe from one process to another ? ... – patro Jun 26 '13 at 16:09
  • You can certainly send the address through a pipe and then use `process_vm_*` to access that memory. But unless you intend to only run your code yourself I would advise you use only common IPC mechanisms like `pipe`, `socketpair`. Linux 3.x will not be deployed on any serious server in the next 2-3 years, so any code you develop for that won't be portable. – Sergey L. Jun 26 '13 at 23:45
  • thanks ...i was able to do it. Just one more point. Why are they not going to deploy it on a serious server? This kernel has been there for quite some time now right? – patro Jul 07 '13 at 02:29
  • 1
    Because it takes a while until new software is considered stable enough to be deployed. And the paranoia about new implementations can go on for years. We are still stuck on Linux 2.6.28 just because we know it's stable and it works. I have heard NASA just recently approved 80386 to be shot into space. – Sergey L. Jul 07 '13 at 11:51

1 Answers1

2

The system calls process_vm_readv and process_vm_writev are meant for fast data transfer between processes. They are supposed to be used in addition to some traditional way of interprocess communication.

For example, you may use a regular pipe or fifo to transfer the required addresses between your processes. Then you may use those addresses to establish faster process_vm_ communication. The simpliest way to transfer something between forked processes should be the pipe() function (man 2 pipe has a good example of its usage). There are many other ways to do so of course, like using sockets or messages. You can even write an address to a file and let the other process read it.

Pavel Zhuravlev
  • 2,691
  • 1
  • 18
  • 17
  • Thanks a lot ...I am trying to send a pointer using pipes and file descriptor. – patro Jun 26 '13 at 16:21
  • http://stackoverflow.com/questions/17325712/cross-memory-attach-not-able-to-send-the-remote-address-using-pipes I have continued the question on this link. Please go through it once – patro Jun 26 '13 at 16:36