Add a (currently disabled) bear trap where instead of deallocating pages, we remove all permissions.

llvm-svn: 124012
This commit is contained in:
Jim Ingham 2011-01-22 01:22:51 +00:00
parent e02657b181
commit 50646ab3e1
1 changed files with 9 additions and 2 deletions

View File

@ -626,7 +626,7 @@ MachTask::AllocateMemory (size_t size, uint32_t permissions)
if (err.Error() == KERN_SUCCESS)
{
// Set the protections:
vm_prot_t mach_prot = 0;
vm_prot_t mach_prot = VM_PROT_NONE;
if (permissions & eMemoryPermissionsReadable)
mach_prot |= VM_PROT_READ;
if (permissions & eMemoryPermissionsWritable)
@ -663,7 +663,14 @@ MachTask::DeallocateMemory (nub_addr_t addr)
if ((*pos).first == addr)
{
m_allocations.erase(pos);
return ::mach_vm_deallocate (task, (*pos).first, (*pos).second) == KERN_SUCCESS;
#define ALWAYS_ZOMBIE_ALLOCATIONS 0
if (ALWAYS_ZOMBIE_ALLOCATIONS || getenv ("DEBUGSERVER_ZOMBIE_ALLOCATIONS"))
{
::mach_vm_protect (task, (*pos).first, (*pos).second, 0, VM_PROT_NONE);
return true;
}
else
return ::mach_vm_deallocate (task, (*pos).first, (*pos).second) == KERN_SUCCESS;
}
}