Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_exec.c
Show First 20 Lines • Show All 1,142 Lines • ▼ Show 20 Lines | exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv) | ||||
error = vm_map_stack(map, stack_addr, (vm_size_t)ssiz, stack_prot, | error = vm_map_stack(map, stack_addr, (vm_size_t)ssiz, stack_prot, | ||||
VM_PROT_ALL, MAP_STACK_GROWS_DOWN); | VM_PROT_ALL, MAP_STACK_GROWS_DOWN); | ||||
if (error != KERN_SUCCESS) { | if (error != KERN_SUCCESS) { | ||||
uprintf("exec_new_vmspace: mapping stack size %#jx prot %#x " | uprintf("exec_new_vmspace: mapping stack size %#jx prot %#x " | ||||
"failed mach error %d errno %d\n", (uintmax_t)ssiz, | "failed mach error %d errno %d\n", (uintmax_t)ssiz, | ||||
stack_prot, error, vm_mmap_to_errno(error)); | stack_prot, error, vm_mmap_to_errno(error)); | ||||
return (vm_mmap_to_errno(error)); | return (vm_mmap_to_errno(error)); | ||||
} | } | ||||
vmspace->vm_stkgap = 0; | |||||
/* | /* | ||||
* vm_ssize and vm_maxsaddr are somewhat antiquated concepts, but they | * vm_ssize and vm_maxsaddr are somewhat antiquated concepts, but they | ||||
* are still used to enforce the stack rlimit on the process stack. | * are still used to enforce the stack rlimit on the process stack. | ||||
*/ | */ | ||||
vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT; | vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT; | ||||
vmspace->vm_maxsaddr = (char *)stack_addr; | vmspace->vm_maxsaddr = (char *)stack_addr; | ||||
▲ Show 20 Lines • Show All 329 Lines • ▼ Show 20 Lines | exec_args_get_begin_envv(struct image_args *args) | ||||
if (args->envc > 0) | if (args->envc > 0) | ||||
return (args->begin_envv); | return (args->begin_envv); | ||||
return (args->endp); | return (args->endp); | ||||
} | } | ||||
void | void | ||||
exec_stackgap(struct image_params *imgp, uintptr_t *dp) | exec_stackgap(struct image_params *imgp, uintptr_t *dp) | ||||
{ | { | ||||
struct proc *p = imgp->proc; | |||||
if (imgp->sysent->sv_stackgap == NULL || | if (imgp->sysent->sv_stackgap == NULL || | ||||
(imgp->proc->p_fctl0 & (NT_FREEBSD_FCTL_ASLR_DISABLE | | (p->p_fctl0 & (NT_FREEBSD_FCTL_ASLR_DISABLE | | ||||
NT_FREEBSD_FCTL_ASG_DISABLE)) != 0 || | NT_FREEBSD_FCTL_ASG_DISABLE)) != 0 || | ||||
(imgp->map_flags & MAP_ASLR) == 0) | (imgp->map_flags & MAP_ASLR) == 0) { | ||||
p->p_vmspace->vm_stkgap = 0; | |||||
return; | return; | ||||
imgp->sysent->sv_stackgap(imgp, dp); | } | ||||
p->p_vmspace->vm_stkgap = imgp->sysent->sv_stackgap(imgp, dp); | |||||
kib: Make sv_stackgap method return the gap value, and assign it to vm_stkgap there. | |||||
Not Done Inline ActionsI suggest to add local struct proc *p var, initialized with imgp->proc. Then you can simplify at least three lines in the function. kib: I suggest to add local struct proc *p var, initialized with imgp->proc. Then you can simplify… | |||||
} | } | ||||
/* | /* | ||||
* Copy strings out to the new process address space, constructing new arg | * Copy strings out to the new process address space, constructing new arg | ||||
* and env vector tables. Return a pointer to the base so that it can be used | * and env vector tables. Return a pointer to the base so that it can be used | ||||
* as the initial stack pointer. | * as the initial stack pointer. | ||||
*/ | */ | ||||
int | int | ||||
▲ Show 20 Lines • Show All 454 Lines • Show Last 20 Lines |
Make sv_stackgap method return the gap value, and assign it to vm_stkgap there.