[CRIU] [PATCH 01/12]v2 page-read: add print error in case of bad or corrupted image

Tikhomirov Pavel snorcht at gmail.com
Mon Dec 16 02:55:25 PST 2013


1. add it instead of BUG_ON
we should print error if flag isn't assigned
2. correct use of read_pagemap_page_from_parent, provide no flag

Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
 page-read.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/page-read.c b/page-read.c
index 83820fa..c416462 100644
--- a/page-read.c
+++ b/page-read.c
@@ -83,7 +83,7 @@ static void skip_pagemap_pages(struct page_read *pr, unsigned long len)
 	pr->cvaddr += len;
 }
 
-static int read_pagemap_page_from_parent(struct page_read *pr, unsigned long vaddr, void *buf)
+static int read_pagemap_page_from_parent(struct page_read *pr, unsigned long vaddr, void *buf, int flags)
 {
 	int ret;
 	struct iovec iov;
@@ -96,7 +96,12 @@ static int read_pagemap_page_from_parent(struct page_read *pr, unsigned long vad
 	while (1) {
 		unsigned long iov_end;
 
-		BUG_ON(vaddr < pr->cvaddr);
+		if (vaddr < pr->cvaddr) {
+			if (!flags & 1) /* Don't print error when flag is set */
+				pr_err("Missing %lu in parent pagemap, current iov: base=%lu,len=%lu\n",
+					vaddr, (unsigned long)iov.iov_base, iov.iov_len);
+			return -1;
+		}
 		iov_end = (unsigned long)iov.iov_base + iov.iov_len;
 
 		if (iov_end <= vaddr) {
@@ -121,7 +126,7 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, void *bu
 
 	if (pr->pe->in_parent) {
 		pr_debug("\tpr%u Read page %lx from parent\n", pr->id, vaddr);
-		ret = read_pagemap_page_from_parent(pr->parent, vaddr, buf);
+		ret = read_pagemap_page_from_parent(pr->parent, vaddr, buf, 0);
 		if (ret == -1)
 			return ret;
 	} else {
-- 
1.7.9.5



More information about the CRIU mailing list