[CRIU] [PATCH] page-read: fix open_page_read usage
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Sat Jun 25 01:26:35 PDT 2016
1. Fix uninitialized use of pr in cr_dedup_one_pagemap and get_page:
https://github.com/xemul/criu/issues/178
2. If open_page_read ret is >0 pr.close is initialized so there is no
point to test it before use
3. In find_vmas fix pr leak in case of error returned from
collect_uffd_pages
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/cr-dedup.c | 6 ++----
criu/uffd.c | 15 +++++++--------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/criu/cr-dedup.c b/criu/cr-dedup.c
index 538f650..ca5a930 100644
--- a/criu/cr-dedup.c
+++ b/criu/cr-dedup.c
@@ -66,10 +66,8 @@ static int cr_dedup_one_pagemap(int pid)
struct iovec iov;
ret = open_page_read(pid, &pr, PR_TASK | PR_MOD);
- if (ret <= 0) {
- ret = -1;
- goto exit;
- }
+ if (ret <= 0)
+ return -1;
prp = pr.parent;
if (!prp)
diff --git a/criu/uffd.c b/criu/uffd.c
index a920ae7..10cc4f2 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -333,6 +333,8 @@ static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
ret = open_page_read(lpi->pid, &pr, PR_TASK | PR_MOD);
pr_debug("get_page ret %d\n", ret);
+ if (ret <= 0)
+ return ret;
ret = pr.get_pagemap(&pr, &iov);
pr_debug("get_pagemap ret %d\n", ret);
@@ -351,8 +353,7 @@ static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
memcpy(dest, buf, PAGE_SIZE);
- if (pr.close)
- pr.close(&pr);
+ pr.close(&pr);
return 1;
}
@@ -619,20 +620,18 @@ static int find_vmas(struct lazy_pages_info *lpi)
*/
do {
ret = collect_uffd_pages(&pr, lpi);
- if (ret == -1) {
- goto out;
- }
+ if (ret == -1)
+ goto close;
} while (ret);
- if (pr.close)
- pr.close(&pr);
-
/* Count detected pages */
list_for_each_entry(uffd_pages, &lpi->pages, list)
ret++;
pr_debug("Found %d pages to be handled by UFFD\n", ret);
+close:
+ pr.close(&pr);
out:
return ret;
}
--
2.5.5
More information about the CRIU
mailing list