diff options
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r-- | sys/kern/kern_exec.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index d8377674a712..e2611ba6f944 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -360,7 +360,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p) struct nameidata nd; struct ucred *oldcred; struct uidinfo *euip = NULL; - register_t *stack_base; + uintptr_t stack_base; struct image_params image_params, *imgp; struct vattr attr; int (*img_first)(struct image_params *); @@ -868,7 +868,7 @@ interpret: #endif /* Set values passed into the program in registers. */ - (*p->p_sysent->sv_setregs)(td, imgp, (u_long)(uintptr_t)stack_base); + (*p->p_sysent->sv_setregs)(td, imgp, stack_base); vfs_mark_atime(imgp->vp, td->td_ucred); @@ -1574,12 +1574,12 @@ exec_args_get_begin_envv(struct image_args *args) * as the initial stack pointer. */ int -exec_copyout_strings(struct image_params *imgp, register_t **stack_base) +exec_copyout_strings(struct image_params *imgp, uintptr_t *stack_base) { int argc, envc; char **vectp; char *stringp; - uintptr_t destp; + uintptr_t destp, ustringp; struct ps_strings *arginfo; struct proc *p; size_t execpath_len; @@ -1650,20 +1650,24 @@ exec_copyout_strings(struct image_params *imgp, register_t **stack_base) return (error); imgp->pagesizeslen = szps; + /* + * Allocate room for the argument and environment strings. + */ destp -= ARG_MAX - imgp->args->stringspace; destp = rounddown2(destp, sizeof(void *)); + ustringp = destp; - vectp = (char **)destp; if (imgp->sysent->sv_stackgap != NULL) - imgp->sysent->sv_stackgap(imgp, (u_long *)&vectp); + imgp->sysent->sv_stackgap(imgp, &destp); if (imgp->auxargs) { - error = imgp->sysent->sv_copyout_auxargs(imgp, - (u_long *)&vectp); + error = imgp->sysent->sv_copyout_auxargs(imgp, &destp); if (error != 0) return (error); } + vectp = (char **)destp; + /* * Allocate room for the argv[] and env vectors including the * terminating NULL pointers. @@ -1673,7 +1677,7 @@ exec_copyout_strings(struct image_params *imgp, register_t **stack_base) /* * vectp also becomes our initial stack base */ - *stack_base = (register_t *)vectp; + *stack_base = (uintptr_t)vectp; stringp = imgp->args->begin_argv; argc = imgp->args->argc; @@ -1682,7 +1686,7 @@ exec_copyout_strings(struct image_params *imgp, register_t **stack_base) /* * Copy out strings - arguments and environment. */ - error = copyout(stringp, (void *)destp, + error = copyout(stringp, (void *)ustringp, ARG_MAX - imgp->args->stringspace); if (error != 0) return (error); @@ -1698,11 +1702,11 @@ exec_copyout_strings(struct image_params *imgp, register_t **stack_base) * Fill in argument portion of vector table. */ for (; argc > 0; --argc) { - if (suword(vectp++, (long)(intptr_t)destp) != 0) + if (suword(vectp++, ustringp) != 0) return (EFAULT); while (*stringp++ != 0) - destp++; - destp++; + ustringp++; + ustringp++; } /* a null vector table pointer separates the argp's from the envp's */ @@ -1717,11 +1721,11 @@ exec_copyout_strings(struct image_params *imgp, register_t **stack_base) * Fill in environment portion of vector table. */ for (; envc > 0; --envc) { - if (suword(vectp++, (long)(intptr_t)destp) != 0) + if (suword(vectp++, ustringp) != 0) return (EFAULT); while (*stringp++ != 0) - destp++; - destp++; + ustringp++; + ustringp++; } /* end of vector table is a null pointer */ |