Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/imgact_elf.c
Show First 20 Lines • Show All 1,442 Lines • ▼ Show 20 Lines | |||||
#define elf_suword __CONCAT(suword, __ELF_WORD_SIZE) | #define elf_suword __CONCAT(suword, __ELF_WORD_SIZE) | ||||
int | int | ||||
__elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base) | __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base) | ||||
{ | { | ||||
Elf_Auxargs *args = (Elf_Auxargs *)imgp->auxargs; | Elf_Auxargs *args = (Elf_Auxargs *)imgp->auxargs; | ||||
Elf_Auxinfo *argarray, *pos; | Elf_Auxinfo *argarray, *pos; | ||||
struct vmspace *vmspace; | struct vmspace *vmspace; | ||||
int error; | rlim_t stacksz; | ||||
int error, bsdflags, oc; | |||||
argarray = pos = malloc(AT_COUNT * sizeof(*pos), M_TEMP, | argarray = pos = malloc(AT_COUNT * sizeof(*pos), M_TEMP, | ||||
M_WAITOK | M_ZERO); | M_WAITOK | M_ZERO); | ||||
vmspace = imgp->proc->p_vmspace; | vmspace = imgp->proc->p_vmspace; | ||||
if (args->execfd != -1) | if (args->execfd != -1) | ||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); | AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); | ||||
Show All 24 Lines | __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base) | ||||
} | } | ||||
AUXARGS_ENTRY(pos, AT_STACKPROT, imgp->sysent->sv_shared_page_obj | AUXARGS_ENTRY(pos, AT_STACKPROT, imgp->sysent->sv_shared_page_obj | ||||
!= NULL && imgp->stack_prot != 0 ? imgp->stack_prot : | != NULL && imgp->stack_prot != 0 ? imgp->stack_prot : | ||||
imgp->sysent->sv_stackprot); | imgp->sysent->sv_stackprot); | ||||
if (imgp->sysent->sv_hwcap != NULL) | if (imgp->sysent->sv_hwcap != NULL) | ||||
AUXARGS_ENTRY(pos, AT_HWCAP, *imgp->sysent->sv_hwcap); | AUXARGS_ENTRY(pos, AT_HWCAP, *imgp->sysent->sv_hwcap); | ||||
if (imgp->sysent->sv_hwcap2 != NULL) | if (imgp->sysent->sv_hwcap2 != NULL) | ||||
AUXARGS_ENTRY(pos, AT_HWCAP2, *imgp->sysent->sv_hwcap2); | AUXARGS_ENTRY(pos, AT_HWCAP2, *imgp->sysent->sv_hwcap2); | ||||
AUXARGS_ENTRY(pos, AT_BSDFLAGS, __elfN(sigfastblock) ? | bsdflags = 0; | ||||
ELF_BSDF_SIGFASTBLK : 0); | bsdflags |= __elfN(sigfastblock) ? ELF_BSDF_SIGFASTBLK : 0; | ||||
oc = atomic_load_int(&vm_overcommit); | |||||
bsdflags |= (oc & (SWAP_RESERVE_FORCE_ON | SWAP_RESERVE_RLIMIT_ON)) != | |||||
0 ? ELF_BSDF_VMNOOVERCOMMIT : 0; | |||||
AUXARGS_ENTRY(pos, AT_BSDFLAGS, bsdflags); | |||||
AUXARGS_ENTRY(pos, AT_ARGC, imgp->args->argc); | AUXARGS_ENTRY(pos, AT_ARGC, imgp->args->argc); | ||||
AUXARGS_ENTRY_PTR(pos, AT_ARGV, imgp->argv); | AUXARGS_ENTRY_PTR(pos, AT_ARGV, imgp->argv); | ||||
AUXARGS_ENTRY(pos, AT_ENVC, imgp->args->envc); | AUXARGS_ENTRY(pos, AT_ENVC, imgp->args->envc); | ||||
AUXARGS_ENTRY_PTR(pos, AT_ENVV, imgp->envv); | AUXARGS_ENTRY_PTR(pos, AT_ENVV, imgp->envv); | ||||
AUXARGS_ENTRY_PTR(pos, AT_PS_STRINGS, imgp->ps_strings); | AUXARGS_ENTRY_PTR(pos, AT_PS_STRINGS, imgp->ps_strings); | ||||
#ifdef RANDOM_FENESTRASX | #ifdef RANDOM_FENESTRASX | ||||
if ((imgp->sysent->sv_flags & SV_RNG_SEED_VER) != 0) { | if ((imgp->sysent->sv_flags & SV_RNG_SEED_VER) != 0) { | ||||
AUXARGS_ENTRY(pos, AT_FXRNG, | AUXARGS_ENTRY(pos, AT_FXRNG, | ||||
vmspace->vm_shp_base + imgp->sysent->sv_fxrng_gen_offset); | vmspace->vm_shp_base + imgp->sysent->sv_fxrng_gen_offset); | ||||
} | } | ||||
#endif | #endif | ||||
if ((imgp->sysent->sv_flags & SV_DSO_SIG) != 0 && __elfN(vdso) != 0) { | if ((imgp->sysent->sv_flags & SV_DSO_SIG) != 0 && __elfN(vdso) != 0) { | ||||
AUXARGS_ENTRY(pos, AT_KPRELOAD, | AUXARGS_ENTRY(pos, AT_KPRELOAD, | ||||
vmspace->vm_shp_base + imgp->sysent->sv_vdso_offset); | vmspace->vm_shp_base + imgp->sysent->sv_vdso_offset); | ||||
} | } | ||||
AUXARGS_ENTRY(pos, AT_USRSTACKBASE, round_page(vmspace->vm_stacktop)); | |||||
PROC_LOCK(imgp->proc); | |||||
mjg: there should be no need to take the lock here. instead i would assert curthread->td_limit ==… | |||||
stacksz = lim_cur_proc(imgp->proc, RLIMIT_STACK); | |||||
PROC_UNLOCK(imgp->proc); | |||||
AUXARGS_ENTRY(pos, AT_USRSTACKLIM, stacksz); | |||||
AUXARGS_ENTRY(pos, AT_NULL, 0); | AUXARGS_ENTRY(pos, AT_NULL, 0); | ||||
free(imgp->auxargs, M_TEMP); | free(imgp->auxargs, M_TEMP); | ||||
imgp->auxargs = NULL; | imgp->auxargs = NULL; | ||||
KASSERT(pos - argarray <= AT_COUNT, ("Too many auxargs")); | KASSERT(pos - argarray <= AT_COUNT, ("Too many auxargs")); | ||||
error = copyout(argarray, (void *)base, sizeof(*argarray) * AT_COUNT); | error = copyout(argarray, (void *)base, sizeof(*argarray) * AT_COUNT); | ||||
free(argarray, M_TEMP); | free(argarray, M_TEMP); | ||||
▲ Show 20 Lines • Show All 1,399 Lines • Show Last 20 Lines |
there should be no need to take the lock here. instead i would assert curthread->td_limit == imgp->proc->p_limit. it matters because it is likely contend against the parent doing wait after forking