[CRIU] [PATCH 07/10] uffd: Check for uffd event being PF early

Pavel Emelyanov xemul at virtuozzo.com
Fri Nov 11 21:25:18 PST 2016


The event received should be checked to be #PF before
accessing its other arguments.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/uffd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index 43d8e7a..96b5ec0 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -668,6 +668,11 @@ static int handle_user_fault(struct lazy_pages_info *lpi, void *dest)
 		return -1;
 	}
 
+	if (msg.event != UFFD_EVENT_PAGEFAULT) {
+		pr_err("unexpected msg event %u\n", msg.event);
+		return -1;
+	}
+
 	/* Align requested address to the next page boundary */
 	address = msg.arg.pagefault.address & ~(page_size() - 1);
 	pr_debug("msg.arg.pagefault.address 0x%llx\n", address);
@@ -681,11 +686,6 @@ static int handle_user_fault(struct lazy_pages_info *lpi, void *dest)
 	flags = msg.arg.pagefault.flags;
 	pr_debug("msg.arg.pagefault.flags 0x%llx\n", flags);
 
-	if (msg.event != UFFD_EVENT_PAGEFAULT) {
-		pr_err("unexpected msg event %u\n", msg.event);
-		return -1;
-	}
-
 	ret = handle_regular_pages(lpi, dest, address);
 	if (ret < 0) {
 		pr_err("Error during regular page copy\n");
-- 
2.5.0



More information about the CRIU mailing list