diff --git a/parasite-syscall.c b/parasite-syscall.c index e77579265..e92f1768d 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -239,7 +239,7 @@ static void *mmap_seized(struct parasite_ctl *ctl, err = syscall_seized(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset); - if (err < 0 || (long)map < 0) + if (err < 0 || map > TASK_SIZE) map = 0; return (void *)map; diff --git a/pie/parasite.c b/pie/parasite.c index fec12b044..1cd8c8127 100644 --- a/pie/parasite.c +++ b/pie/parasite.c @@ -45,7 +45,7 @@ static int brk_init(void) ret = sys_mmap(NULL, MAX_HEAP_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (ret < 0) + if (ret > TASK_SIZE) return -ENOMEM; brk_start = brk_tail = (void *)ret; @@ -427,7 +427,7 @@ static int init(struct parasite_init_args *args) PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if ((long)tid_state < 0) + if ((unsigned long)tid_state > TASK_SIZE) return -ENOMEM; nr_tid_state = args->nr_threads;