Commit 02168054 authored by Pavel Emelyanov's avatar Pavel Emelyanov

rst-malloc: Do not grow sh-remap memory

The mremap() grow on anonymous shared memory doesn't produce
usable segment, as the underlying kernel tmpfs file doesn't
get truncated. So any access to new mem will result in sigbus.

Disable this grow for now, we only need few of such memory.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 7c2542a8
...@@ -66,7 +66,18 @@ static int grow_remap(struct rst_mem_type_s *t, int flag, unsigned long size) ...@@ -66,7 +66,18 @@ static int grow_remap(struct rst_mem_type_s *t, int flag, unsigned long size)
*/ */
aux = mmap(NULL, size, PROT_READ | PROT_WRITE, aux = mmap(NULL, size, PROT_READ | PROT_WRITE,
flag | MAP_ANON, 0, 0); flag | MAP_ANON, 0, 0);
else else {
if (flag & MAP_SHARED) {
/*
* Anon shared memory cannot grow with
* mremap, anon-shmem file size doesn't
* chage and memory access generates
* SIGBUS. We should truncate the guy,
* but for now we don't need it.
*/
pr_err("Can't grow RM_SHREMAP memory\n");
return -1;
}
/* /*
* We'll have to remap all objects into restorer * We'll have to remap all objects into restorer
* address space and get their new addresses. Since * address space and get their new addresses. Since
...@@ -78,6 +89,7 @@ static int grow_remap(struct rst_mem_type_s *t, int flag, unsigned long size) ...@@ -78,6 +89,7 @@ static int grow_remap(struct rst_mem_type_s *t, int flag, unsigned long size)
*/ */
aux = mremap(t->buf, t->size, aux = mremap(t->buf, t->size,
t->size + size, MREMAP_MAYMOVE); t->size + size, MREMAP_MAYMOVE);
}
if (aux == MAP_FAILED) if (aux == MAP_FAILED)
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment