[msan] Replicate mmap-below-shadow check in mmap64 interceptor.

llvm-svn: 201397
This commit is contained in:
Evgeniy Stepanov 2014-02-14 09:49:29 +00:00
parent 8c1441f860
commit fb74ea80dc
2 changed files with 10 additions and 0 deletions

View File

@ -5,6 +5,8 @@
// RUN: %clangxx_msan -m64 -O0 -DFIXED=0 %s -o %t && %t
// RUN: %clangxx_msan -m64 -O0 -DFIXED=1 %s -o %t && %t
// RUN: %clangxx_msan -m64 -O0 -DFIXED=0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
// RUN: %clangxx_msan -m64 -O0 -DFIXED=1 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
#include <assert.h>
#include <errno.h>

View File

@ -814,6 +814,14 @@ INTERCEPTOR(void *, mmap, void *addr, SIZE_T length, int prot, int flags,
INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags,
int fd, OFF64_T offset) {
ENSURE_MSAN_INITED();
if (addr && !MEM_IS_APP(addr)) {
if (flags & map_fixed) {
*__errno_location() = errno_EINVAL;
return (void *)-1;
} else {
addr = 0;
}
}
void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset);
if (res != (void*)-1)
__msan_unpoison(res, RoundUpTo(length, GetPageSize()));