title: Pointer to a memory location of another process
body: <p>I have come across this question: </p>
  
  <blockquote>
    <p>If process A contains a pointer to a variable in process B, is it
    possible for A to access and modify that variable?</p>
  </blockquote>
  
  <p>My intuition is that, since processes A and B are different, they should not be allowed to access each other's address space since it will violate the protection.</p>
  
  <p>But after some thinking, the following questions popped in my mind and want to get clarified.</p>
  
  <p>(i). When we say A has a pointer to a variable V in B, does A holds the virtual address (of process B) corresponding to V or the physical address?</p>
  
  <p>I believe when we talk about address in virtual memory systems, we always talk about virtual address. Please clarify.</p>
  
  <p>(ii). If A contains the virtual address, since it is possible that both A and B can have the same virtual address, it is possible that A's pagetable contains a mapping for the virtual address that A holds (which is actually the virtual address of variable V in process B).
  Then when A tries to access and modify that virtual address, it modifies something in its own address space (this access will be allowed since A accesses its own address).</p>
  
  <p>I think the above reasoning applies when we try to access some random virtual address from a process i.e., accidentally the address that we try to access has a valid mapping. </p>
  
  <p>Please throw your thoughts.</p>