[CRIU] [PATCH v2] page-read: fix open_page_read usage
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Tue Jun 28 08:44:11 PDT 2016
1. Fix uninitialized use of pr in cr_dedup_one_pagemap and get_page:
https://github.com/xemul/criu/issues/178
2. In lpi_fini, if open_page_read ret was >0 pr.close is initialized
so there is no point to test it before use
3. In ud_open, fix pr leak in case of error returned from find_vmas->
collect_uffd_pages as we free lpi with lpi->pr allocated; so do check
in lpi_fini if we have pr set and that uffd is >0 before close
v2:rebase to new criu-dev
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/cr-dedup.c | 6 ++----
criu/uffd.c | 6 +++---
2 files changed, 5 insertions(+), 7 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 1e0a57a..a525103 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -76,9 +76,9 @@ static struct lazy_pages_info *lpi_init(void)
static void lpi_fini(struct lazy_pages_info *lpi)
{
- if (lpi->uffd)
+ if (lpi->uffd > 0)
close(lpi->uffd);
- if (lpi->pr.close)
+ if (lpi->pr)
lpi->pr.close(&lpi->pr);
free(lpi);
}
@@ -323,7 +323,7 @@ static struct lazy_pages_info *ud_open(int listen, struct sockaddr_un *saddr)
return lpi;
out:
- free(lpi);
+ lpi_fini(lpi);
close_safe(&client);
return NULL;
}
--
2.5.5
More information about the CRIU
mailing list