2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

x86/compat: fix error-check for compat mmap()

Raw sys_mmap() returns address or error like -ENOMEM.
Don't check MAP_FAILED, check that result is aligned by page.

travis-ci: success for x86/compat: fix error-check for compat mmap()
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Dmitry Safonov
2017-01-18 19:26:00 +03:00
committed by Andrei Vagin
parent f5cad87d5b
commit 6cacaa69d6

View File

@@ -16,8 +16,12 @@ static inline void *alloc_compat_syscall_stack(void)
void *mem = (void*)sys_mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, void *mem = (void*)sys_mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (mem == MAP_FAILED) if ((uintptr_t)mem % PAGE_SIZE) {
int err = (~(uint32_t)(uintptr_t)mem) + 1;
pr_err("mmap() of compat syscall stack failed with %d\n", err);
return 0; return 0;
}
return mem; return mem;
} }
@@ -26,7 +30,7 @@ static inline void free_compat_syscall_stack(void *mem)
long int ret = sys_munmap(mem, PAGE_SIZE); long int ret = sys_munmap(mem, PAGE_SIZE);
if (ret) if (ret)
pr_err("munmap of compat addr %p failed with %ld", mem, ret); pr_err("munmap() of compat addr %p failed with %ld", mem, ret);
} }
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT