thread: randomize user stack position

Use B_RANDOMIZE_BASE_ADDRESS for creating both main and other threads user
stack.
This commit is contained in:
Pawel Dziepak
2013-04-04 15:16:22 +02:00
parent b3e4c67739
commit 17c189899a
+3 -12
View File
@@ -821,19 +821,10 @@ create_thread_user_stack(Team* team, Thread* thread, void* _stackBase,
snprintf(nameBuffer, B_OS_NAME_LENGTH, "%s_%" B_PRId32 "_stack",
thread->name, thread->id);
virtual_address_restrictions virtualRestrictions = {};
if (thread->id == team->id) {
// The main thread gets a fixed position at the top of the stack
// address range.
stackBase = (uint8*)(USER_STACK_REGION + USER_STACK_REGION_SIZE
- areaSize);
virtualRestrictions.address_specification = B_EXACT_ADDRESS;
stackBase = (uint8*)USER_STACK_REGION;
} else {
// not a main thread
stackBase = (uint8*)(addr_t)USER_STACK_REGION;
virtualRestrictions.address_specification = B_BASE_ADDRESS;
}
virtual_address_restrictions virtualRestrictions = {};
virtualRestrictions.address_specification = B_RANDOMIZED_BASE_ADDRESS;
virtualRestrictions.address = (void*)stackBase;
physical_address_restrictions physicalRestrictions = {};