forked from OSchip/llvm-project
[msan] Replicate mmap-below-shadow check in mmap64 interceptor.
llvm-svn: 201397
This commit is contained in:
parent
8c1441f860
commit
fb74ea80dc
|
@ -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>
|
||||
|
|
|
@ -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()));
|
||||
|
|
Loading…
Reference in New Issue