thread: randomize user stack position
Use B_RANDOMIZE_BASE_ADDRESS for creating both main and other threads user stack.
This commit is contained in:
@@ -821,19 +821,10 @@ create_thread_user_stack(Team* team, Thread* thread, void* _stackBase,
|
|||||||
snprintf(nameBuffer, B_OS_NAME_LENGTH, "%s_%" B_PRId32 "_stack",
|
snprintf(nameBuffer, B_OS_NAME_LENGTH, "%s_%" B_PRId32 "_stack",
|
||||||
thread->name, thread->id);
|
thread->name, thread->id);
|
||||||
|
|
||||||
virtual_address_restrictions virtualRestrictions = {};
|
stackBase = (uint8*)USER_STACK_REGION;
|
||||||
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;
|
|
||||||
|
|
||||||
} else {
|
virtual_address_restrictions virtualRestrictions = {};
|
||||||
// not a main thread
|
virtualRestrictions.address_specification = B_RANDOMIZED_BASE_ADDRESS;
|
||||||
stackBase = (uint8*)(addr_t)USER_STACK_REGION;
|
|
||||||
virtualRestrictions.address_specification = B_BASE_ADDRESS;
|
|
||||||
}
|
|
||||||
virtualRestrictions.address = (void*)stackBase;
|
virtualRestrictions.address = (void*)stackBase;
|
||||||
|
|
||||||
physical_address_restrictions physicalRestrictions = {};
|
physical_address_restrictions physicalRestrictions = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user