[CRIU] [RFC PATCH v2 08/23] lazy-pages: update drop_lazy_iovs to handle addresses outside IOVs

Mike Rapoport rppt at linux.vnet.ibm.com
Mon Feb 6 03:44:01 PST 2017


Currently drop_lazy_iovs presumes that the range that should be dropped
starts inside an IOV. This works fine with page faults and background pages
but will fail for mapping changes.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/uffd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index bfd5c4c..b9d9233 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -340,12 +340,17 @@ static int drop_lazy_iovs(struct lazy_pages_info *lpi, unsigned long addr,
 		unsigned long start = iov->base;
 		unsigned long end = start + iov->len;
 
-		if (len <= 0)
+		if (len <= 0 || addr + len < start)
 			break;
 
-		if (addr < start || addr >= end)
+		if (addr >= end)
 			continue;
 
+		if (addr < start) {
+			len -= (start - addr);
+			addr = start;
+		}
+
 		/*
 		 * The range completely fits into the current IOV.
 		 * If addr equals iov_base we just "drop" the
-- 
1.9.1



More information about the CRIU mailing list