Use uintptr_t instead of register_t * for the stack base.

- Use ustringp for the location of the argv and environment strings
  and allow destp to travel further down the stack for the stackgap
  and auxv regions.
- Update the Linux copyout_strings variants to move destp down the
  stack as was done for the native ABIs in r263349.
- Stop allocating a space for a stack gap in the Linux ABIs.  This
  used to hold translated system call arguments, but hasn't been used
  since r159992.

Reviewed by:	kib
Tested on:	md64 (amd64, i386, linux64), i386 (i386, linux)
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D22501
This commit is contained in:
jhb 2019-12-03 23:17:54 +00:00
parent d137f58263
commit 0d8d23a6a3
36 changed files with 291 additions and 250 deletions

View File

@ -577,7 +577,7 @@ freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap)
* Reset registers to default values on exec.
*/
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *regs;
struct pcb *pcb;

View File

@ -53,7 +53,7 @@ extern struct sysent cloudabi32_sysent[];
extern unsigned long ia32_maxssiz;
static int
cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp)
cloudabi32_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp)
{
int error;
uint32_t args[2];
@ -73,16 +73,16 @@ cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp)
* refer to the auxiliary vector, which is stored right after
* the TCB.
*/
args[0] = (uintptr_t)*stack_base;
args[1] = (uintptr_t)*stack_base +
args[0] = *stack_base;
args[1] = *stack_base +
roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
*stack_base -= howmany(sizeof(args), sizeof(register_t));
return (copyout(args, *stack_base, sizeof(args)));
*stack_base -= roundup2(sizeof(args), sizeof(register_t));
return (copyout(args, (void *)*stack_base, sizeof(args)));
}
static void
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
unsigned long stack)
uintptr_t stack)
{
ia32_setregs(td, imgp, stack);

View File

@ -48,7 +48,7 @@ extern const char *cloudabi64_syscallnames[];
extern struct sysent cloudabi64_sysent[];
static int
cloudabi64_fixup_tcb(register_t **stack_base, struct image_params *imgp)
cloudabi64_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp)
{
int error;
register_t tcbptr;
@ -64,12 +64,13 @@ cloudabi64_fixup_tcb(register_t **stack_base, struct image_params *imgp)
* containing a pointer to the TCB. %fs base will point to this.
*/
tcbptr = (register_t)*stack_base;
return (copyout(&tcbptr, --*stack_base, sizeof(tcbptr)));
*stack_base -= sizeof(tcbptr);
return (copyout(&tcbptr, (void *)*stack_base, sizeof(tcbptr)));
}
static void
cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp,
unsigned long stack)
uintptr_t stack)
{
struct trapframe *regs;

View File

@ -936,7 +936,7 @@ freebsd32_sigreturn(td, uap)
* Clear registers on exec
*/
void
ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
ia32_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *regs;
struct pcb *pcb;

View File

@ -97,8 +97,8 @@ extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
static int linux_copyout_strings(struct image_params *imgp,
register_t **stack_base);
static int linux_fixup_elf(register_t **stack_base,
uintptr_t *stack_base);
static int linux_fixup_elf(uintptr_t *stack_base,
struct image_params *iparams);
static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
static void linux_vdso_install(void *param);
@ -106,7 +106,7 @@ static void linux_vdso_deinstall(void *param);
static void linux_set_syscall_retval(struct thread *td, int error);
static int linux_fetch_syscall_args(struct thread *td);
static void linux_exec_setregs(struct thread *td, struct image_params *imgp,
u_long stack);
uintptr_t stack);
static int linux_vsyscall(struct thread *td);
#define LINUX_T_UNKNOWN 255
@ -224,7 +224,7 @@ linux_set_syscall_retval(struct thread *td, int error)
}
static int
linux_copyout_auxargs(struct image_params *imgp, u_long *base)
linux_copyout_auxargs(struct image_params *imgp, uintptr_t *base)
{
Elf_Auxargs *args;
Elf_Auxinfo *argarray, *pos;
@ -274,7 +274,7 @@ linux_copyout_auxargs(struct image_params *imgp, u_long *base)
}
static int
linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp)
{
Elf_Addr *base;
@ -283,7 +283,7 @@ linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
if (suword(base, (uint64_t)imgp->args->argc) == -1)
return (EFAULT);
*stack_base = (register_t *)base;
*stack_base = (uintptr_t)base;
return (0);
}
@ -293,11 +293,12 @@ linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
* as the initial stack pointer.
*/
static int
linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
{
int argc, envc, error;
char **vectp;
char *stringp, *destp;
char *stringp;
uintptr_t destp, ustringp;
struct ps_strings *arginfo;
char canary[LINUX_AT_RANDOM_LEN];
size_t execpath_len;
@ -311,43 +312,45 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
p = imgp->proc;
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
destp = (caddr_t)arginfo - SPARE_USRSPACE -
roundup(sizeof(canary), sizeof(char *)) -
roundup(execpath_len, sizeof(char *)) -
roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
destp = (uintptr_t)arginfo;
if (execpath_len != 0) {
imgp->execpathp = (uintptr_t)arginfo - execpath_len;
error = copyout(imgp->execpath, (void *)imgp->execpathp,
execpath_len);
destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len);
if (error != 0)
return (error);
}
/* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0);
imgp->canary = (uintptr_t)arginfo -
roundup(execpath_len, sizeof(char *)) -
roundup(sizeof(canary), sizeof(char *));
error = copyout(canary, (void *)imgp->canary, sizeof(canary));
destp -= roundup(sizeof(canary), sizeof(void *));
imgp->canary = destp;
error = copyout(canary, (void *)destp, sizeof(canary));
if (error != 0)
return (error);
vectp = (char **)destp;
/* Allocate room for the argument and environment strings. */
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(void *));
ustringp = destp;
/*
* Starting with 2.24, glibc depends on a 16-byte stack alignment.
* One "long argc" will be prepended later.
*/
vectp = (char **)((((uintptr_t)vectp + 8) & ~0xF) - 8);
if (destp % 16 == 0)
destp -= 8;
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.
@ -355,14 +358,15 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
/* 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;
envc = imgp->args->envc;
/* Copy out strings - arguments and environment. */
error = copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
error = copyout(stringp, (void *)ustringp,
ARG_MAX - imgp->args->stringspace);
if (error != 0)
return (error);
@ -373,11 +377,11 @@ linux_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. */
@ -390,11 +394,11 @@ linux_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++;
}
/* The end of the vector table is a null pointer. */
@ -408,7 +412,8 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
* Reset registers to default values on exec.
*/
static void
linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
linux_exec_setregs(struct thread *td, struct image_params *imgp,
uintptr_t stack)
{
struct trapframe *regs;
struct pcb *pcb;

View File

@ -101,13 +101,13 @@ extern struct sysent linux32_sysent[LINUX32_SYS_MAXSYSCALL];
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
static int linux_fixup_elf(register_t **stack_base,
static int linux_fixup_elf(uintptr_t *stack_base,
struct image_params *iparams);
static int linux_copyout_strings(struct image_params *imgp,
register_t **stack_base);
uintptr_t *stack_base);
static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
static void linux_exec_setregs(struct thread *td,
struct image_params *imgp, u_long stack);
struct image_params *imgp, uintptr_t stack);
static void linux32_fixlimit(struct rlimit *rl, int which);
static bool linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
static void linux_vdso_install(void *param);
@ -246,7 +246,7 @@ linux_copyout_auxargs(struct image_params *imgp, u_long *base)
}
static int
linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp)
{
Elf32_Addr *base;
@ -254,7 +254,7 @@ linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
base--;
if (suword32(base, (uint32_t)imgp->args->argc) == -1)
return (EFAULT);
*stack_base = (register_t *)base;
*stack_base = (uintptr_t)base;
return (0);
}
@ -677,7 +677,8 @@ linux32_fetch_syscall_args(struct thread *td)
* XXX copied from ia32_signal.c.
*/
static void
linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
linux_exec_setregs(struct thread *td, struct image_params *imgp,
uintptr_t stack)
{
struct trapframe *regs = td->td_frame;
struct pcb *pcb = td->td_pcb;
@ -721,11 +722,12 @@ linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
* XXX copied from ia32_sysvec.c.
*/
static int
linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
{
int argc, envc, error;
u_int32_t *vectp;
char *stringp, *destp;
char *stringp;
uintptr_t destp, ustringp;
struct linux32_ps_strings *arginfo;
char canary[LINUX_AT_RANDOM_LEN];
size_t execpath_len;
@ -737,36 +739,38 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
execpath_len = 0;
arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
destp = (caddr_t)arginfo - SPARE_USRSPACE -
roundup(sizeof(canary), sizeof(char *)) -
roundup(execpath_len, sizeof(char *)) -
roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
destp = (uintptr_t)arginfo;
if (execpath_len != 0) {
imgp->execpathp = (uintptr_t)arginfo - execpath_len;
error = copyout(imgp->execpath, (void *)imgp->execpathp,
execpath_len);
destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len);
if (error != 0)
return (error);
}
/* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0);
imgp->canary = (uintptr_t)arginfo -
roundup(execpath_len, sizeof(char *)) -
roundup(sizeof(canary), sizeof(char *));
error = copyout(canary, (void *)imgp->canary, sizeof(canary));
destp -= roundup(sizeof(canary), sizeof(void *));
imgp->canary = destp;
error = copyout(canary, (void *)destp, sizeof(canary));
if (error != 0)
return (error);
vectp = (uint32_t *)destp;
/* Allocate room for the argument and environment strings. */
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(void *));
ustringp = 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 = (uint32_t *)destp;
/*
* Allocate room for the argv[] and env vectors including the
* terminating NULL pointers.
@ -774,13 +778,15 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
/* 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;
envc = imgp->args->envc;
/* Copy out strings - arguments and environment. */
error = copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
error = copyout(stringp, (void *)ustringp,
ARG_MAX - imgp->args->stringspace);
if (error != 0)
return (error);
@ -791,11 +797,11 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
/* Fill in argument portion of vector table. */
for (; argc > 0; --argc) {
if (suword32(vectp++, (uint32_t)(intptr_t)destp) != 0)
if (suword32(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. */
@ -808,11 +814,11 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
/* Fill in environment portion of vector table. */
for (; envc > 0; --envc) {
if (suword32(vectp++, (uint32_t)(intptr_t)destp) != 0)
if (suword32(vectp++, ustringp) != 0)
return (EFAULT);
while (*stringp++ != 0)
destp++;
destp++;
ustringp++;
ustringp++;
}
/* The end of the vector table is a null pointer. */

View File

@ -412,7 +412,7 @@ spinlock_exit(void)
* Clear registers on exec
*/
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *tf = td->td_frame;

View File

@ -49,7 +49,7 @@ extern struct sysent cloudabi32_sysent[];
static void
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
unsigned long stack)
uintptr_t stack)
{
struct trapframe *regs;

View File

@ -232,7 +232,7 @@ freebsd32_set_syscall_retval(struct thread *td, int error)
static void
freebsd32_setregs(struct thread *td, struct image_params *imgp,
u_long stack)
uintptr_t stack)
{
struct trapframe *tf = td->td_frame;

View File

@ -436,7 +436,7 @@ ptrace_clear_single_step(struct thread *td)
}
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *tf = td->td_frame;

View File

@ -49,7 +49,7 @@ extern struct sysent cloudabi32_sysent[];
static void
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
unsigned long stack)
uintptr_t stack)
{
struct trapframe *regs;

View File

@ -49,7 +49,7 @@ extern struct sysent cloudabi64_sysent[];
static void
cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp,
unsigned long stack)
uintptr_t stack)
{
struct trapframe *regs;

View File

@ -70,8 +70,8 @@ extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
static int linux_copyout_strings(struct image_params *imgp,
register_t **stack_base);
static int linux_elf_fixup(register_t **stack_base,
uintptr_t *stack_base);
static int linux_elf_fixup(uintptr_t *stack_base,
struct image_params *iparams);
static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
static void linux_vdso_install(const void *param);
@ -79,7 +79,7 @@ static void linux_vdso_deinstall(const void *param);
static void linux_set_syscall_retval(struct thread *td, int error);
static int linux_fetch_syscall_args(struct thread *td);
static void linux_exec_setregs(struct thread *td, struct image_params *imgp,
u_long stack);
uintptr_t stack);
static int linux_vsyscall(struct thread *td);
/* DTrace init */
@ -143,7 +143,7 @@ linux_set_syscall_retval(struct thread *td, int error)
}
static int
linux_copyout_auxargs(struct image_params *imgp, u_long *base)
linux_copyout_auxargs(struct image_params *imgp, uintptr_t *base)
{
Elf_Auxargs *args;
Elf_Auxinfo *argarray, *pos;
@ -198,7 +198,7 @@ linux_copyout_auxargs(struct image_params *imgp, u_long *base)
}
static int
linux_elf_fixup(register_t **stack_base, struct image_params *imgp)
linux_elf_fixup(uintptr_t *stack_base, struct image_params *imgp)
{
LIN_SDT_PROBE0(sysvec, linux_elf_fixup, todo);
@ -213,10 +213,11 @@ linux_elf_fixup(register_t **stack_base, struct image_params *imgp)
* LINUXTODO: deduplicate against other linuxulator archs
*/
static int
linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
{
char **vectp;
char *stringp, *destp;
char *stringp;
uintptr_t *destp, *ustringp;
struct ps_strings *arginfo;
char canary[LINUX_AT_RANDOM_LEN];
size_t execpath_len;
@ -231,36 +232,38 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
p = imgp->proc;
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
destp = (caddr_t)arginfo - SPARE_USRSPACE -
roundup(sizeof(canary), sizeof(char *)) -
roundup(execpath_len, sizeof(char *)) -
roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
destp = (uintptr_t)arginfo;
if (execpath_len != 0) {
imgp->execpathp = (uintptr_t)arginfo - execpath_len;
error = copyout(imgp->execpath, (void *)imgp->execpathp,
execpath_len);
destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len);
if (error != 0)
return (error);
}
/* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0);
imgp->canary = (uintptr_t)arginfo -
roundup(execpath_len, sizeof(char *)) -
roundup(sizeof(canary), sizeof(char *));
error = copyout(canary, (void *)imgp->canary, sizeof(canary));
destp -= roundup(sizeof(canary), sizeof(void *));
imgp->canary = destp;
error = copyout(canary, (void *)destp, sizeof(canary));
if (error != 0)
return (error);
vectp = (char **)destp;
/* Allocate room for the argument and environment strings. */
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(void *));
ustringp = 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 argc and the argv[] and env vectors including the
* terminating NULL pointers.
@ -269,14 +272,15 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
vectp = (char **)STACKALIGN(vectp);
/* 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;
envc = imgp->args->envc;
/* Copy out strings - arguments and environment. */
error = copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
error = copyout(stringp, (void *)ustringp,
ARG_MAX - imgp->args->stringspace);
if (error != 0)
return (error);
@ -290,11 +294,11 @@ linux_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. */
@ -307,11 +311,11 @@ linux_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++;
}
/* The end of the vector table is a null pointer. */
@ -325,7 +329,8 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
* Reset registers to default values on exec.
*/
static void
linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
linux_exec_setregs(struct thread *td, struct image_params *imgp,
uintptr_t stack)
{
struct trapframe *regs = td->td_frame;

View File

@ -46,7 +46,7 @@ extern char _binary_cloudabi32_vdso_o_start[];
extern char _binary_cloudabi32_vdso_o_end[];
int
cloudabi32_copyout_strings(struct image_params *imgp, register_t **stack_base)
cloudabi32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
{
struct image_args *args;
uintptr_t begin;
@ -56,12 +56,12 @@ cloudabi32_copyout_strings(struct image_params *imgp, register_t **stack_base)
args = imgp->args;
len = exec_args_get_begin_envv(args) - args->begin_argv;
begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t));
*stack_base = (register_t *)begin;
*stack_base = begin;
return (copyout(args->begin_argv, (void *)begin, len));
}
int
cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
cloudabi32_fixup(uintptr_t *stack_base, struct image_params *imgp)
{
char canarybuf[64], pidbuf[16];
Elf32_Auxargs *args;
@ -79,12 +79,12 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
td = curthread;
td->td_proc->p_osrel = __FreeBSD_version;
argdata = *stack_base;
argdata = (void *)*stack_base;
/* Store canary for stack smashing protection. */
arc4rand(canarybuf, sizeof(canarybuf), 0);
*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
canary = *stack_base;
*stack_base -= roundup(sizeof(canarybuf), sizeof(register_t));
canary = (void *)*stack_base;
error = copyout(canarybuf, canary, sizeof(canarybuf));
if (error != 0)
return (error);
@ -97,8 +97,8 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
arc4rand(pidbuf, sizeof(pidbuf), 0);
pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
*stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
pid = *stack_base;
*stack_base -= roundup(sizeof(pidbuf), sizeof(register_t));
pid = (void *)*stack_base;
error = copyout(pidbuf, pid, sizeof(pidbuf));
if (error != 0)
return (error);
@ -135,13 +135,13 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
#undef PTR
{ .a_type = CLOUDABI_AT_NULL },
};
*stack_base -= howmany(sizeof(auxv), sizeof(register_t));
error = copyout(auxv, *stack_base, sizeof(auxv));
*stack_base -= roundup(sizeof(auxv), sizeof(register_t));
error = copyout(auxv, (void *)*stack_base, sizeof(auxv));
if (error != 0)
return (error);
/* Reserve space for storing the TCB. */
*stack_base -= howmany(sizeof(cloudabi32_tcb_t), sizeof(register_t));
*stack_base -= roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
return (0);
}

View File

@ -42,8 +42,8 @@ extern Elf32_Brandinfo cloudabi32_brand;
#define TO_PTR(x) ((void *)(uintptr_t)(x))
/* Stack initialization during process execution. */
int cloudabi32_copyout_strings(struct image_params *, register_t **);
int cloudabi32_fixup(register_t **, struct image_params *);
int cloudabi32_copyout_strings(struct image_params *, uintptr_t *);
int cloudabi32_fixup(uintptr_t *, struct image_params *);
int cloudabi32_thread_setregs(struct thread *,
const cloudabi32_threadattr_t *, uint32_t);

View File

@ -46,7 +46,7 @@ extern char _binary_cloudabi64_vdso_o_start[];
extern char _binary_cloudabi64_vdso_o_end[];
int
cloudabi64_copyout_strings(struct image_params *imgp, register_t **stack_base)
cloudabi64_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
{
struct image_args *args;
uintptr_t begin;
@ -56,12 +56,12 @@ cloudabi64_copyout_strings(struct image_params *imgp, register_t **stack_base)
args = imgp->args;
len = exec_args_get_begin_envv(args) - args->begin_argv;
begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t));
*stack_base = (register_t *)begin;
*stack_base = begin;
return (copyout(args->begin_argv, (void *)begin, len));
}
int
cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
cloudabi64_fixup(uintptr_t *stack_base, struct image_params *imgp)
{
char canarybuf[64], pidbuf[16];
Elf64_Auxargs *args;
@ -79,12 +79,12 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
td = curthread;
td->td_proc->p_osrel = __FreeBSD_version;
argdata = *stack_base;
argdata = (void *)*stack_base;
/* Store canary for stack smashing protection. */
arc4rand(canarybuf, sizeof(canarybuf), 0);
*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
canary = *stack_base;
*stack_base -= roundup(sizeof(canarybuf), sizeof(register_t));
canary = (void *)*stack_base;
error = copyout(canarybuf, canary, sizeof(canarybuf));
if (error != 0)
return (error);
@ -97,8 +97,8 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
arc4rand(pidbuf, sizeof(pidbuf), 0);
pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
*stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
pid = *stack_base;
*stack_base -= roundup(sizeof(pidbuf), sizeof(register_t));
pid = (void *)*stack_base;
error = copyout(pidbuf, pid, sizeof(pidbuf));
if (error != 0)
return (error);
@ -135,13 +135,13 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
#undef PTR
{ .a_type = CLOUDABI_AT_NULL },
};
*stack_base -= howmany(sizeof(auxv), sizeof(register_t));
error = copyout(auxv, *stack_base, sizeof(auxv));
*stack_base -= roundup(sizeof(auxv), sizeof(register_t));
error = copyout(auxv, (void *)*stack_base, sizeof(auxv));
if (error != 0)
return (error);
/* Reserve space for storing the TCB. */
*stack_base -= howmany(sizeof(cloudabi64_tcb_t), sizeof(register_t));
*stack_base -= roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t));
return (0);
}

View File

@ -42,8 +42,8 @@ extern Elf64_Brandinfo cloudabi64_brand;
#define TO_PTR(x) ((void *)(uintptr_t)(x))
/* Stack initialization during process execution. */
int cloudabi64_copyout_strings(struct image_params *, register_t **);
int cloudabi64_fixup(register_t **, struct image_params *);
int cloudabi64_copyout_strings(struct image_params *, uintptr_t *);
int cloudabi64_fixup(uintptr_t *, struct image_params *);
int cloudabi64_thread_setregs(struct thread *,
const cloudabi64_threadattr_t *, uint64_t);

View File

@ -3120,12 +3120,12 @@ syscall32_helper_unregister(struct syscall_helper_data *sd)
}
int
freebsd32_copyout_strings(struct image_params *imgp, register_t **stack_base)
freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
{
int argc, envc, i;
u_int32_t *vectp;
char *stringp;
uintptr_t destp;
uintptr_t destp, ustringp;
struct freebsd32_ps_strings *arginfo;
char canary[sizeof(long) * 8];
int32_t pagesizes32[MAXPAGESIZES];
@ -3195,20 +3195,24 @@ freebsd32_copyout_strings(struct image_params *imgp, register_t **stack_base)
return (error);
imgp->pagesizeslen = sizeof(pagesizes32);
/*
* Allocate room for the argument and environment strings.
*/
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(uint32_t));
ustringp = destp;
vectp = (uint32_t *)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 = (uint32_t *)destp;
/*
* Allocate room for the argv[] and env vectors including the
* terminating NULL pointers.
@ -3218,7 +3222,7 @@ freebsd32_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;
@ -3226,7 +3230,7 @@ freebsd32_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);
@ -3242,11 +3246,11 @@ freebsd32_copyout_strings(struct image_params *imgp, register_t **stack_base)
* Fill in argument portion of vector table.
*/
for (; argc > 0; --argc) {
if (suword32(vectp++, (u_int32_t)(intptr_t)destp) != 0)
if (suword32(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 */
@ -3261,11 +3265,11 @@ freebsd32_copyout_strings(struct image_params *imgp, register_t **stack_base)
* Fill in environment portion of vector table.
*/
for (; envc > 0; --envc) {
if (suword32(vectp++, (u_int32_t)(intptr_t)destp) != 0)
if (suword32(vectp++, ustringp) != 0)
return (EFAULT);
while (*stringp++ != 0)
destp++;
destp++;
ustringp++;
ustringp++;
}
/* end of vector table is a null pointer */

View File

@ -113,7 +113,7 @@ int syscall32_helper_unregister(struct syscall_helper_data *sd);
struct iovec32;
struct rusage32;
int freebsd32_copyout_strings(struct image_params *imgp,
register_t **stack_base);
uintptr_t *stack_base);
int freebsd32_copyiniov(struct iovec32 *iovp, u_int iovcnt,
struct iovec **iov, int error);
void freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32);

View File

@ -206,7 +206,7 @@ extern int sz_ia32_osigcode;
extern int sz_lcall_tramp;
void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *);
void ia32_setregs(struct thread *td, struct image_params *imgp,
u_long stack);
uintptr_t stack);
int setup_lcall_gate(void);
#endif

View File

@ -48,7 +48,7 @@ extern const char *cloudabi32_syscallnames[];
extern struct sysent cloudabi32_sysent[];
static int
cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp)
cloudabi32_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp)
{
int error;
uint32_t args[2];
@ -68,16 +68,16 @@ cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp)
* refer to the auxiliary vector, which is stored right after
* the TCB.
*/
args[0] = (uintptr_t)*stack_base;
args[1] = (uintptr_t)*stack_base +
args[0] = *stack_base;
args[1] = *stack_base +
roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
*stack_base -= howmany(sizeof(args), sizeof(register_t));
return (copyout(args, *stack_base, sizeof(args)));
*stack_base -= roundup(sizeof(args), sizeof(register_t));
return (copyout(args, (void *)*stack_base, sizeof(args)));
}
static void
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
unsigned long stack)
uintptr_t stack)
{
exec_setregs(td, imgp, stack);

View File

@ -1124,7 +1124,7 @@ setup_priv_lcall_gate(struct proc *p)
* Reset registers to default values on exec.
*/
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *regs;
struct pcb *pcb;

View File

@ -88,15 +88,15 @@ extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
static int linux_fixup(register_t **stack_base,
static int linux_fixup(uintptr_t *stack_base,
struct image_params *iparams);
static int linux_fixup_elf(register_t **stack_base,
static int linux_fixup_elf(uintptr_t *stack_base,
struct image_params *iparams);
static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
static void linux_exec_setregs(struct thread *td,
struct image_params *imgp, u_long stack);
struct image_params *imgp, uintptr_t stack);
static int linux_copyout_strings(struct image_params *imgp,
register_t **stack_base);
uintptr_t *stack_base);
static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
static void linux_vdso_install(void *param);
static void linux_vdso_deinstall(void *param);
@ -174,23 +174,25 @@ linux_translate_traps(int signal, int trap_code)
}
static int
linux_fixup(register_t **stack_base, struct image_params *imgp)
linux_fixup(uintptr_t *stack_base, struct image_params *imgp)
{
register_t *argv, *envp;
register_t *base, *argv, *envp;
argv = *stack_base;
envp = *stack_base + (imgp->args->argc + 1);
(*stack_base)--;
suword(*stack_base, (intptr_t)(void *)envp);
(*stack_base)--;
suword(*stack_base, (intptr_t)(void *)argv);
(*stack_base)--;
suword(*stack_base, imgp->args->argc);
base = (register_t *)*stack_base;
argv = base;
envp = base + (imgp->args->argc + 1);
base--;
suword(base, (intptr_t)envp);
base--;
suword(base, (intptr_t)argv);
base--;
suword(base, imgp->args->argc);
*stack_base = (uintptr_t)base;
return (0);
}
static int
linux_copyout_auxargs(struct image_params *imgp, u_long *base)
linux_copyout_auxargs(struct image_params *imgp, uintptr_t *base)
{
struct proc *p;
Elf32_Auxargs *args;
@ -255,12 +257,15 @@ linux_copyout_auxargs(struct image_params *imgp, u_long *base)
}
static int
linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp)
{
register_t *base;
(*stack_base)--;
if (suword(*stack_base, (register_t)imgp->args->argc) == -1)
base = (register_t *)*stack_base;
base--;
if (suword(base, (register_t)imgp->args->argc) == -1)
return (EFAULT);
*stack_base = (uintptr_t)base;
return (0);
}
@ -268,11 +273,12 @@ linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
* Copied from kern/kern_exec.c
*/
static int
linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
{
int argc, envc, error;
char **vectp;
char *stringp, *destp;
char *stringp;
uintptr_t destp, ustringp;
struct ps_strings *arginfo;
char canary[LINUX_AT_RANDOM_LEN];
size_t execpath_len;
@ -285,43 +291,45 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
else
execpath_len = 0;
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
destp = (caddr_t)arginfo - SPARE_USRSPACE - linux_szplatform -
roundup(sizeof(canary), sizeof(char *)) -
roundup(execpath_len, sizeof(char *)) -
roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
destp = (uintptr_t)arginfo;
/* Install LINUX_PLATFORM. */
error = copyout(linux_kplatform, ((caddr_t)arginfo - linux_szplatform),
linux_szplatform);
destp -= linux_szplatform;
destp = rounddown2(destp, sizeof(void *));
error = copyout(linux_kplatform, (void *)destp, linux_szplatform);
if (error != 0)
return (error);
if (execpath_len != 0) {
imgp->execpathp = (uintptr_t)arginfo -
linux_szplatform - execpath_len;
error = copyout(imgp->execpath, (void *)imgp->execpathp,
execpath_len);
destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len);
if (error != 0)
return (error);
}
/* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0);
imgp->canary = (uintptr_t)arginfo - linux_szplatform -
roundup(execpath_len, sizeof(char *)) -
roundup(sizeof(canary), sizeof(char *));
error = copyout(canary, (void *)imgp->canary, sizeof(canary));
destp -= roundup(sizeof(canary), sizeof(void *));
imgp->canary = destp;
error = copyout(canary, (void *)destp, sizeof(canary));
if (error != 0)
return (error);
vectp = (char **)destp;
/* Allocate room for the argument and environment strings. */
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(void *));
ustringp = 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.
@ -329,14 +337,15 @@ linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
/* 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;
envc = imgp->args->envc;
/* Copy out strings - arguments and environment. */
error = copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
error = copyout(stringp, (void *)ustringp,
ARG_MAX - imgp->args->stringspace);
if (error != 0)
return (error);
@ -347,11 +356,11 @@ linux_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. */
@ -364,11 +373,11 @@ linux_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++;
}
/* The end of the vector table is a null pointer. */
@ -781,7 +790,8 @@ linux_fetch_syscall_args(struct thread *td)
* override the exec_setregs default(s) here.
*/
static void
linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
linux_exec_setregs(struct thread *td, struct image_params *imgp,
uintptr_t stack)
{
struct pcb *pcb = td->td_pcb;

View File

@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
#endif
static int exec_aout_imgact(struct image_params *imgp);
static int aout_fixup(register_t **stack_base, struct image_params *imgp);
static int aout_fixup(uintptr_t *stack_base, struct image_params *imgp);
#define AOUT32_USRSTACK 0xbfc00000
@ -147,11 +147,13 @@ struct sysentvec aout_sysvec = {
#endif
static int
aout_fixup(register_t **stack_base, struct image_params *imgp)
aout_fixup(uintptr_t *stack_base, struct image_params *imgp)
{
*(char **)stack_base -= sizeof(uint32_t);
return (suword32(*stack_base, imgp->args->argc));
*stack_base -= sizeof(uint32_t);
if (suword32((void *)*stack_base, imgp->args->argc) != 0)
return (EFAULT);
return (0);
}
static int

View File

@ -1324,7 +1324,7 @@ ret:
#define suword __CONCAT(suword, __ELF_WORD_SIZE)
int
__elfN(freebsd_copyout_auxargs)(struct image_params *imgp, u_long *base)
__elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t *base)
{
Elf_Auxargs *args = (Elf_Auxargs *)imgp->auxargs;
Elf_Auxinfo *argarray, *pos;
@ -1382,7 +1382,7 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, u_long *base)
}
int
__elfN(freebsd_fixup)(register_t **stack_base, struct image_params *imgp)
__elfN(freebsd_fixup)(uintptr_t *stack_base, struct image_params *imgp)
{
Elf_Addr *base;
@ -1390,7 +1390,7 @@ __elfN(freebsd_fixup)(register_t **stack_base, struct image_params *imgp)
base--;
if (suword(base, imgp->args->argc) == -1)
return (EFAULT);
*stack_base = (register_t *)base;
*stack_base = (uintptr_t)base;
return (0);
}
@ -2750,9 +2750,9 @@ __elfN(untrans_prot)(vm_prot_t prot)
}
void
__elfN(stackgap)(struct image_params *imgp, u_long *stack_base)
__elfN(stackgap)(struct image_params *imgp, uintptr_t *stack_base)
{
u_long range, rbase, gap;
uintptr_t range, rbase, gap;
int pct;
if ((imgp->map_flags & MAP_ASLR) == 0)

View File

@ -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 */

View File

@ -68,7 +68,8 @@
#include <compat/freebsd32/freebsd32_util.h>
#include <compat/freebsd32/freebsd32_proto.h>
static void freebsd32_exec_setregs(struct thread *, struct image_params *, u_long);
static void freebsd32_exec_setregs(struct thread *, struct image_params *,
uintptr_t);
static int get_mcontext32(struct thread *, mcontext32_t *, int);
static int set_mcontext32(struct thread *, mcontext32_t *);
static void freebsd32_sendsig(sig_t, ksiginfo_t *, sigset_t *);
@ -126,7 +127,8 @@ SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST,
&freebsd_brand_info);
static void
freebsd32_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
freebsd32_exec_setregs(struct thread *td, struct image_params *imgp,
uintptr_t stack)
{
exec_setregs(td, imgp, stack);

View File

@ -410,7 +410,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs)
* code by the MIPS elf abi).
*/
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
bzero((caddr_t)td->td_frame, sizeof(struct trapframe));

View File

@ -73,7 +73,7 @@ struct image_params;
int fill_regs32(struct thread *, struct reg32 *);
int set_regs32(struct thread *, struct reg32 *);
void ppc32_setregs(struct thread *, struct image_params *, u_long);
void ppc32_setregs(struct thread *, struct image_params *, uintptr_t);
#define fill_fpregs32(td, reg) fill_fpregs(td,(struct fpreg *)reg)
#define set_fpregs32(td, reg) set_fpregs(td,(struct fpreg *)reg)

View File

@ -53,7 +53,7 @@
#include <machine/md_var.h>
static void exec_setregs_funcdesc(struct thread *td, struct image_params *imgp,
u_long stack);
uintptr_t stack);
struct sysentvec elf64_freebsd_sysvec_v1 = {
.sv_size = SYS_MAXSYSCALL,
@ -207,7 +207,7 @@ ppc64_elfv2_header_match(struct image_params *params)
static void
exec_setregs_funcdesc(struct thread *td, struct image_params *imgp,
u_long stack)
uintptr_t stack)
{
struct trapframe *tf;
register_t entry_desc[3];

View File

@ -539,7 +539,7 @@ cleanup_power_extras(struct thread *td)
* Set set up registers on exec.
*/
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *tf;
register_t argc;
@ -585,7 +585,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
#ifdef COMPAT_FREEBSD32
void
ppc32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
ppc32_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *tf;
uint32_t argc;

View File

@ -297,7 +297,7 @@ ptrace_clear_single_step(struct thread *td)
}
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *tf;
struct pcb *pcb;

View File

@ -978,12 +978,12 @@ ptrace_clear_single_step(struct thread *td)
}
void
exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *tf;
struct pcb *pcb;
struct proc *p;
u_long sp;
uintptr_t sp;
/* XXX no cpu_exec */
p = td->td_proc;

View File

@ -110,10 +110,10 @@ int exec_args_adjust_args(struct image_args *args, size_t consume,
ssize_t extend);
char *exec_args_get_begin_envv(struct image_args *args);
int exec_check_permissions(struct image_params *);
int exec_copyout_strings(struct image_params *, register_t **);
int exec_copyout_strings(struct image_params *, uintptr_t *);
void exec_free_args(struct image_args *);
int exec_new_vmspace(struct image_params *, struct sysentvec *);
void exec_setregs(struct thread *, struct image_params *, u_long);
void exec_setregs(struct thread *, struct image_params *, uintptr_t);
int exec_shell_imgact(struct image_params *);
int exec_copyin_args(struct image_args *, const char *, enum uio_seg,
char **, char **);

View File

@ -95,11 +95,11 @@ __ElfType(Brandinfo);
int __elfN(brand_inuse)(Elf_Brandinfo *entry);
int __elfN(insert_brand_entry)(Elf_Brandinfo *entry);
int __elfN(remove_brand_entry)(Elf_Brandinfo *entry);
int __elfN(freebsd_fixup)(register_t **, struct image_params *);
int __elfN(freebsd_fixup)(uintptr_t *, struct image_params *);
int __elfN(coredump)(struct thread *, struct vnode *, off_t, int);
size_t __elfN(populate_note)(int, void *, void *, size_t, void **);
void __elfN(stackgap)(struct image_params *, u_long *);
int __elfN(freebsd_copyout_auxargs)(struct image_params *, u_long *);
void __elfN(stackgap)(struct image_params *, uintptr_t *);
int __elfN(freebsd_copyout_auxargs)(struct image_params *, uintptr_t *);
/* Machine specific function to dump per-thread information. */
void __elfN(dump_thread)(struct thread *, void *, size_t *);

View File

@ -99,7 +99,7 @@ struct sysentvec {
const int *sv_errtbl; /* errno translation table */
int (*sv_transtrap)(int, int);
/* translate trap-to-signal mapping */
int (*sv_fixup)(register_t **, struct image_params *);
int (*sv_fixup)(uintptr_t *, struct image_params *);
/* stack fixup function */
void (*sv_sendsig)(void (*)(int), struct ksiginfo *, struct __sigset *);
/* send signal */
@ -109,17 +109,19 @@ struct sysentvec {
int (*sv_coredump)(struct thread *, struct vnode *, off_t, int);
/* function to dump core, or NULL */
int (*sv_imgact_try)(struct image_params *);
void (*sv_stackgap)(struct image_params *, u_long *);
int (*sv_copyout_auxargs)(struct image_params *, u_long *);
void (*sv_stackgap)(struct image_params *, uintptr_t *);
int (*sv_copyout_auxargs)(struct image_params *,
uintptr_t *);
int sv_minsigstksz; /* minimum signal stack size */
vm_offset_t sv_minuser; /* VM_MIN_ADDRESS */
vm_offset_t sv_maxuser; /* VM_MAXUSER_ADDRESS */
vm_offset_t sv_usrstack; /* USRSTACK */
vm_offset_t sv_psstrings; /* PS_STRINGS */
int sv_stackprot; /* vm protection for stack */
int (*sv_copyout_strings)(struct image_params *, register_t **);
int (*sv_copyout_strings)(struct image_params *,
uintptr_t *);
void (*sv_setregs)(struct thread *, struct image_params *,
u_long);
uintptr_t);
void (*sv_fixlimit)(struct rlimit *, int);
u_long *sv_maxssiz;
u_int sv_flags;