From 5ff013391b788a037e9b8bbf4e2008ead18bf4fb Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 18 Dec 2012 20:48:56 +0300 Subject: [PATCH] parasite: Fix exchang area size handling Wrong size was used in mapping and unmapping. But since they are more-less close to each other, nobody noticed it. Signed-off-by: Pavel Emelyanov --- parasite-syscall.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parasite-syscall.c b/parasite-syscall.c index 6c1492b02..c6906612b 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -755,7 +755,7 @@ int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item) } if (ctl->local_map) { - if (munmap(ctl->local_map, parasite_size)) { + if (munmap(ctl->local_map, ctl->map_length)) { pr_err("munmap failed (pid: %d)\n", ctl->pid); ret = -1; } @@ -832,7 +832,7 @@ int parasite_map_exchange(struct parasite_ctl *ctl, unsigned long size) { int fd; - ctl->remote_map = mmap_seized(ctl, NULL, (size_t)parasite_size, + ctl->remote_map = mmap_seized(ctl, NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_SHARED, -1, 0); if (!ctl->remote_map) { @@ -840,14 +840,14 @@ int parasite_map_exchange(struct parasite_ctl *ctl, unsigned long size) return -1; } - ctl->map_length = round_up(parasite_size, PAGE_SIZE); + ctl->map_length = round_up(size, PAGE_SIZE); fd = open_proc_rw(ctl->pid, "map_files/%p-%p", ctl->remote_map, ctl->remote_map + ctl->map_length); if (fd < 0) return -1; - ctl->local_map = mmap(NULL, parasite_size, PROT_READ | PROT_WRITE, + ctl->local_map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FILE, fd, 0); close(fd);