Commit 57d25e7c authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mm: fix expression to determine which vma-s can be shared

Currently only addresses are compared. It's obviously not enough.

* First of all the parent vma must be private.
* Both vma-s must have the identical set of MAP_GROWSDOWN and MAP_FILES
  flags.
* Both vma-s must be linked to the same file.

https://bugzilla.openvz.org/show_bug.cgi?id=2824Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7659c995
...@@ -234,14 +234,24 @@ static int map_private_vma(pid_t pid, struct vma_area *vma, void *tgt_addr, ...@@ -234,14 +234,24 @@ static int map_private_vma(pid_t pid, struct vma_area *vma, void *tgt_addr,
if (p->vma.start > vma->vma.start) if (p->vma.start > vma->vma.start)
break; break;
if (p->vma.end == vma->vma.end && if (!vma_priv(&p->vma))
p->vma.start == vma->vma.start) { continue;
pr_info("COW 0x%016"PRIx64"-0x%016"PRIx64" 0x%016"PRIx64" vma\n",
vma->vma.start, vma->vma.end, vma->vma.pgoff); if (p->vma.end != vma->vma.end ||
paddr = decode_pointer(vma->premmaped_addr); p->vma.start != vma->vma.start)
continue;
/* Check flags, which must be identical for both vma-s */
if ((vma->vma.flags ^ p->vma.flags) & (MAP_GROWSDOWN | MAP_ANONYMOUS))
break;
if (!(vma->vma.flags & MAP_ANONYMOUS) &&
vma->vma.shmid != p->vma.shmid)
break; break;
}
pr_info("COW 0x%016"PRIx64"-0x%016"PRIx64" 0x%016"PRIx64" vma\n",
vma->vma.start, vma->vma.end, vma->vma.pgoff);
paddr = decode_pointer(vma->premmaped_addr);
} }
*pvma = p; *pvma = p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment