[CRIU] [PATCH] ipc_ns: allocate enough memrory for the buffer

Andrey Vagin avagin at openvz.org
Tue May 21 08:25:20 EDT 2013


==22653== Syscall param read(buf) points to unaddressable byte(s)
==22653==    at 0x50480B0: __read_nocancel (in /usr/lib64/libpthread-2.17.so)
==22653==    by 0x40CF7C: parasite_dump_pages_seized (mem.c:244)
==22653==    by 0x41681D: cr_dump_tasks (cr-dump.c:1533)
==22653==    by 0x40448C: main (crtools.c:309)

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 ipc_ns.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipc_ns.c b/ipc_ns.c
index 8511fb8..ff17122 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -530,7 +530,7 @@ static int prepare_ipc_sem_values(int fd, const IpcSemEntry *sem)
 	int ret, size;
 	u16 *values;
 
-	size = sizeof(u16) * sem->nsems;
+	size = round_up(sizeof(u16) * sem->nsems, sizeof(u64));
 	values = xmalloc(size);
 	if (values == NULL) {
 		pr_err("Failed to allocate memory for semaphores set values\n");
@@ -538,7 +538,7 @@ static int prepare_ipc_sem_values(int fd, const IpcSemEntry *sem)
 		goto out;
 	}
 
-	ret = read_img_buf(fd, values, round_up(size, sizeof(u64)));
+	ret = read_img_buf(fd, values, size);
 	if (ret < 0) {
 		pr_err("Failed to allocate memory for semaphores set values\n");
 		ret = -ENOMEM;
-- 
1.8.2



More information about the CRIU mailing list