mmap: Check if size exceeds available memory when MAP_HUGETLB

If size exceeds, mmap fails and set -ENOMEM

Change-Id: I4f0d6e18ee3a7c8e32e251b7ed07ee9f76305603
Refs: #1183
This commit is contained in:
Ken Sato
2019-07-02 15:42:13 +09:00
committed by Masamichi Takagi
parent 2dd8687974
commit 8efced7bf7
11 changed files with 542 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include <page.h>
#include <limits.h>
#include <syscall.h>
#include <rusage_private.h>
#include <ihk/debug.h>
void terminate_mcexec(int, int);
@ -1701,6 +1702,12 @@ SYSCALL_DECLARE(mmap)
}
pgsize = (size_t)1 << ((flags >> MAP_HUGE_SHIFT) & 0x3F);
if (rusage_check_overmap(len0,
(flags >> MAP_HUGE_SHIFT) & 0x3F)) {
error = -ENOMEM;
goto out;
}
}
#define VALID_DUMMY_ADDR ((region->user_start + PTL3_SIZE - 1) & ~(PTL3_SIZE - 1))