[CRIU] [PATCH 8/8] lazy-pages: don't try to uffd_copy to removed memory regions
Mike Rapoport
rppt at linux.vnet.ibm.com
Mon Apr 16 19:59:04 MSK 2018
It is possible that when pages request from the remove source arrive, part
of the memory range covered by the request would be already gone because of
madvise(MADV_DONTNEED), mremap() etc.
Ensure we are not trying to uffd_copy more than we are allowed.
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/uffd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/criu/uffd.c b/criu/uffd.c
index 4022fc5..7f6a59c 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -839,6 +839,7 @@ static int uffd_io_complete(struct page_read *pr, unsigned long img_addr, int nr
{
struct lazy_pages_info *lpi;
unsigned long addr = 0;
+ int req_pages;
struct lazy_iov *req;
lpi = container_of(pr, struct lazy_pages_info, pr);
@@ -864,6 +865,14 @@ static int uffd_io_complete(struct page_read *pr, unsigned long img_addr, int nr
if (!addr)
return 0;
+ /*
+ * by the time we get the pages from the remote source, parts
+ * of the request may already be gone because of
+ * UFFD_EVENT_{REMAP,REMOVE,UNMAP}
+ */
+ req_pages = (req->end - req->start) / PAGE_SIZE;
+ nr = min(nr, req_pages);
+
return uffd_copy(lpi, addr, nr);
}
--
2.7.4
More information about the CRIU
mailing list