Prevent allocating address 0 when inserting an area with B_ANY_ADDRESS.
The USER_BASE_ANY definition exists to specify where to start searching for B_ANY_ADDRESS allocations, but this was not being used correctly. On x86_64, this was causing the runtime loader's heap to be allocated at address 0 so NULL pointer accesses were not getting caught.
This commit is contained in:
@@ -461,8 +461,8 @@ VMUserAddressSpace::_InsertAreaSlot(addr_t start, addr_t size, addr_t end,
|
|||||||
bool foundSpot = false;
|
bool foundSpot = false;
|
||||||
|
|
||||||
TRACE(("VMUserAddressSpace::_InsertAreaSlot: address space %p, start "
|
TRACE(("VMUserAddressSpace::_InsertAreaSlot: address space %p, start "
|
||||||
"0x%lx, size %ld, end 0x%lx, addressSpec %ld, area %p\n", this, start,
|
"0x%lx, size %ld, end 0x%lx, addressSpec %" B_PRIu32 ", area %p\n",
|
||||||
size, end, addressSpec, area));
|
this, start, size, end, addressSpec, area));
|
||||||
|
|
||||||
// do some sanity checking
|
// do some sanity checking
|
||||||
if (start < fBase || size == 0 || end > fEndAddress
|
if (start < fBase || size == 0 || end > fEndAddress
|
||||||
@@ -514,8 +514,8 @@ second_chance:
|
|||||||
// find a hole big enough for a new area
|
// find a hole big enough for a new area
|
||||||
if (last == NULL) {
|
if (last == NULL) {
|
||||||
// see if we can build it at the beginning of the virtual map
|
// see if we can build it at the beginning of the virtual map
|
||||||
addr_t alignedBase = ROUNDUP(fBase, alignment);
|
addr_t alignedBase = ROUNDUP(start, alignment);
|
||||||
if (is_valid_spot(fBase, alignedBase, size,
|
if (is_valid_spot(start, alignedBase, size,
|
||||||
next == NULL ? end : next->Base())) {
|
next == NULL ? end : next->Base())) {
|
||||||
foundSpot = true;
|
foundSpot = true;
|
||||||
area->SetBase(alignedBase);
|
area->SetBase(alignedBase);
|
||||||
|
|||||||
Reference in New Issue
Block a user