Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/imgact_elf.c
Show First 20 Lines • Show All 2,688 Lines • ▼ Show 20 Lines | __elfN(stackgap)(struct image_params *imgp, uintptr_t *stack_base) | ||||
pct = __elfN(aslr_stack_gap); | pct = __elfN(aslr_stack_gap); | ||||
if (pct == 0) | if (pct == 0) | ||||
return; | return; | ||||
if (pct > 50) | if (pct > 50) | ||||
pct = 50; | pct = 50; | ||||
range = imgp->eff_stack_sz * pct / 100; | range = imgp->eff_stack_sz * pct / 100; | ||||
arc4rand(&rbase, sizeof(rbase), 0); | arc4rand(&rbase, sizeof(rbase), 0); | ||||
gap = rbase % range; | gap = rbase % range; | ||||
gap &= ~(sizeof(u_long) - 1); | gap &= ~(sizeof(u_long) - 1); | ||||
kib: I suggest to move the assignment from there to exec_stackgap().
Both to have the set… | |||||
imgp->proc->p_vmspace->vm_stkgap = (vm_offset_t)gap; | |||||
*stack_base -= gap; | *stack_base -= gap; | ||||
} | } |
I suggest to move the assignment from there to exec_stackgap().
Both to have the set up/cleaning in the same place, and to make vm_stkgap initialization non depended on specific image activator.