[CRIU] [PATCH] restore: find VMA for each restored page
Andrey Vagin
avagin at openvz.org
Fri Mar 15 09:24:38 EDT 2013
Otherwise ppage_bitmap and page_bitmap will be updated for wrong VMA
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-restore.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 7c58be8..cef8637 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -296,19 +296,21 @@ static int restore_priv_vma_content(pid_t pid)
BUG_ON(va < vma->vma.start);
- while (va >= vma->vma.end) {
- BUG_ON(vma->list.next == &rst_vmas.h);
- vma = list_entry(vma->list.next, struct vma_area, list);
- }
-
- off = (va - vma->vma.start) / PAGE_SIZE;
for (i = 0; i < pe->nr_pages; i++) {
unsigned char buf[PAGE_SIZE];
void *p;
- set_bit(off + i, vma->page_bitmap);
+ while (va >= vma->vma.end) {
+ BUG_ON(vma->list.next == &rst_vmas.h);
+ vma = list_entry(vma->list.next, struct vma_area, list);
+ }
+
+ off = (va - vma->vma.start) / PAGE_SIZE;
+ va += PAGE_SIZE;
+
+ set_bit(off, vma->page_bitmap);
if (vma->ppage_bitmap)
- clear_bit(off + i, vma->ppage_bitmap);
+ clear_bit(off, vma->ppage_bitmap);
ret = read(fd_pg, buf, PAGE_SIZE);
if (ret != PAGE_SIZE) {
@@ -316,8 +318,9 @@ static int restore_priv_vma_content(pid_t pid)
return -1;
}
- p = (void *)((off + i) * PAGE_SIZE +
+ p = (void *)((off) * PAGE_SIZE +
vma_premmaped_start(&vma->vma));
+
if (memcmp(p, buf, PAGE_SIZE) == 0) {
nr_shared++;
continue;
--
1.7.11.7
More information about the CRIU
mailing list