[sanitizer] rename MmapNoAccess to MmapFixedNoAccess; NFC

llvm-svn: 267253
This commit is contained in:
Kostya Serebryany 2016-04-22 23:46:53 +00:00
parent 58bc64432c
commit 99ed605799
8 changed files with 13 additions and 13 deletions

View File

@ -328,7 +328,7 @@ static void InitializeHighMemEnd() {
static void ProtectGap(uptr addr, uptr size) { static void ProtectGap(uptr addr, uptr size) {
if (!flags()->protect_shadow_gap) if (!flags()->protect_shadow_gap)
return; return;
void *res = MmapNoAccess(addr, size, "shadow gap"); void *res = MmapFixedNoAccess(addr, size, "shadow gap");
if (addr == (uptr)res) if (addr == (uptr)res)
return; return;
// A few pages at the start of the address space can not be protected. // A few pages at the start of the address space can not be protected.
@ -339,7 +339,7 @@ static void ProtectGap(uptr addr, uptr size) {
while (size > step && addr < kZeroBaseMaxShadowStart) { while (size > step && addr < kZeroBaseMaxShadowStart) {
addr += step; addr += step;
size -= step; size -= step;
void *res = MmapNoAccess(addr, size, "shadow gap"); void *res = MmapFixedNoAccess(addr, size, "shadow gap");
if (addr == (uptr)res) if (addr == (uptr)res)
return; return;
} }

View File

@ -411,7 +411,7 @@ static void dfsan_init(int argc, char **argv, char **envp) {
// case by disabling memory protection when ASLR is disabled. // case by disabling memory protection when ASLR is disabled.
uptr init_addr = (uptr)&dfsan_init; uptr init_addr = (uptr)&dfsan_init;
if (!(init_addr >= UnusedAddr() && init_addr < AppAddr())) if (!(init_addr >= UnusedAddr() && init_addr < AppAddr()))
MmapNoAccess(UnusedAddr(), AppAddr() - UnusedAddr()); MmapFixedNoAccess(UnusedAddr(), AppAddr() - UnusedAddr());
InitializeInterceptors(); InitializeInterceptors();

View File

@ -55,14 +55,14 @@ static bool CheckMemoryRangeAvailability(uptr beg, uptr size) {
static bool ProtectMemoryRange(uptr beg, uptr size, const char *name) { static bool ProtectMemoryRange(uptr beg, uptr size, const char *name) {
if (size > 0) { if (size > 0) {
void *addr = MmapNoAccess(beg, size, name); void *addr = MmapFixedNoAccess(beg, size, name);
if (beg == 0 && addr) { if (beg == 0 && addr) {
// Depending on the kernel configuration, we may not be able to protect // Depending on the kernel configuration, we may not be able to protect
// the page at address zero. // the page at address zero.
uptr gap = 16 * GetPageSizeCached(); uptr gap = 16 * GetPageSizeCached();
beg += gap; beg += gap;
size -= gap; size -= gap;
addr = MmapNoAccess(beg, size, name); addr = MmapFixedNoAccess(beg, size, name);
} }
if ((uptr)addr != beg) { if ((uptr)addr != beg) {
uptr end = beg + size - 1; uptr end = beg + size - 1;

View File

@ -324,11 +324,11 @@ class SizeClassAllocator64 {
void Init() { void Init() {
if (kUsingConstantSpaceBeg) { if (kUsingConstantSpaceBeg) {
CHECK_EQ(kSpaceBeg, CHECK_EQ(kSpaceBeg, reinterpret_cast<uptr>(
reinterpret_cast<uptr>(MmapNoAccess(kSpaceBeg, kSpaceSize))); MmapFixedNoAccess(kSpaceBeg, kSpaceSize)));
} else { } else {
NonConstSpaceBeg = reinterpret_cast<uptr>( NonConstSpaceBeg = reinterpret_cast<uptr>(
MmapNoAccess(0, kSpaceSize + AdditionalSize())); MmapFixedNoAccess(0, kSpaceSize + AdditionalSize()));
CHECK_NE(NonConstSpaceBeg, ~(uptr)0); CHECK_NE(NonConstSpaceBeg, ~(uptr)0);
} }
MapWithCallback(SpaceEnd(), AdditionalSize()); MapWithCallback(SpaceEnd(), AdditionalSize());

View File

@ -84,10 +84,10 @@ void *MmapFixedNoReserve(uptr fixed_addr, uptr size,
const char *name = nullptr); const char *name = nullptr);
void *MmapNoReserveOrDie(uptr size, const char *mem_type); void *MmapNoReserveOrDie(uptr size, const char *mem_type);
void *MmapFixedOrDie(uptr fixed_addr, uptr size); void *MmapFixedOrDie(uptr fixed_addr, uptr size);
void *MmapNoAccess(uptr fixed_addr, uptr size, const char *name = nullptr); void *MmapFixedNoAccess(uptr fixed_addr, uptr size, const char *name = nullptr);
// Map aligned chunk of address space; size and alignment are powers of two. // Map aligned chunk of address space; size and alignment are powers of two.
void *MmapAlignedOrDie(uptr size, uptr alignment, const char *mem_type); void *MmapAlignedOrDie(uptr size, uptr alignment, const char *mem_type);
// Disallow access to a memory range. Use MmapNoAccess to allocate an // Disallow access to a memory range. Use MmapFixedNoAccess to allocate an
// unaccessible memory. // unaccessible memory.
bool MprotectNoAccess(uptr addr, uptr size); bool MprotectNoAccess(uptr addr, uptr size);
bool MprotectReadOnly(uptr addr, uptr size); bool MprotectReadOnly(uptr addr, uptr size);

View File

@ -270,7 +270,7 @@ void *MmapFixedNoReserve(uptr fixed_addr, uptr size, const char *name) {
return (void *)p; return (void *)p;
} }
void *MmapNoAccess(uptr fixed_addr, uptr size, const char *name) { void *MmapFixedNoAccess(uptr fixed_addr, uptr size, const char *name) {
int fd = name ? GetNamedMappingFd(name, size) : -1; int fd = name ? GetNamedMappingFd(name, size) : -1;
unsigned flags = MAP_PRIVATE | MAP_FIXED | MAP_NORESERVE; unsigned flags = MAP_PRIVATE | MAP_FIXED | MAP_NORESERVE;
if (fd == -1) flags |= MAP_ANON; if (fd == -1) flags |= MAP_ANON;

View File

@ -200,7 +200,7 @@ void *MmapNoReserveOrDie(uptr size, const char *mem_type) {
return MmapOrDie(size, mem_type); return MmapOrDie(size, mem_type);
} }
void *MmapNoAccess(uptr fixed_addr, uptr size, const char *name) { void *MmapFixedNoAccess(uptr fixed_addr, uptr size, const char *name) {
(void)name; // unsupported (void)name; // unsupported
void *res = VirtualAlloc((LPVOID)fixed_addr, size, void *res = VirtualAlloc((LPVOID)fixed_addr, size,
MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS); MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);

View File

@ -105,7 +105,7 @@ static void ProtectRange(uptr beg, uptr end) {
CHECK_LE(beg, end); CHECK_LE(beg, end);
if (beg == end) if (beg == end)
return; return;
if (beg != (uptr)MmapNoAccess(beg, end - beg)) { if (beg != (uptr)MmapFixedNoAccess(beg, end - beg)) {
Printf("FATAL: ThreadSanitizer can not protect [%zx,%zx]\n", beg, end); Printf("FATAL: ThreadSanitizer can not protect [%zx,%zx]\n", beg, end);
Printf("FATAL: Make sure you are not using unlimited stack\n"); Printf("FATAL: Make sure you are not using unlimited stack\n");
Die(); Die();