Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F110701846
D22501.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
50 KB
Referenced Files
None
Subscribers
None
D22501.diff
View Options
Index: head/sys/amd64/amd64/machdep.c
===================================================================
--- head/sys/amd64/amd64/machdep.c
+++ head/sys/amd64/amd64/machdep.c
@@ -577,7 +577,7 @@
* 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;
Index: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
===================================================================
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
@@ -53,7 +53,7 @@
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 @@
* 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);
Index: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
===================================================================
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
@@ -48,7 +48,7 @@
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 @@
* 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;
Index: head/sys/amd64/ia32/ia32_signal.c
===================================================================
--- head/sys/amd64/ia32/ia32_signal.c
+++ head/sys/amd64/ia32/ia32_signal.c
@@ -936,7 +936,7 @@
* 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;
Index: head/sys/amd64/linux/linux_sysvec.c
===================================================================
--- head/sys/amd64/linux/linux_sysvec.c
+++ head/sys/amd64/linux/linux_sysvec.c
@@ -97,8 +97,8 @@
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_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 @@
}
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 @@
}
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 @@
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 @@
* 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 @@
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 @@
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 @@
/* 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 @@
/* 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 @@
* 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;
Index: head/sys/amd64/linux32/linux32_sysvec.c
===================================================================
--- head/sys/amd64/linux32/linux32_sysvec.c
+++ head/sys/amd64/linux32/linux32_sysvec.c
@@ -101,13 +101,13 @@
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 @@
}
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 @@
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 @@
* 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 @@
* 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 @@
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 @@
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 @@
/* 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 @@
/* 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. */
Index: head/sys/arm/arm/machdep.c
===================================================================
--- head/sys/arm/arm/machdep.c
+++ head/sys/arm/arm/machdep.c
@@ -412,7 +412,7 @@
* 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;
Index: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
===================================================================
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c
@@ -49,7 +49,7 @@
static void
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
- unsigned long stack)
+ uintptr_t stack)
{
struct trapframe *regs;
Index: head/sys/arm64/arm64/elf32_machdep.c
===================================================================
--- head/sys/arm64/arm64/elf32_machdep.c
+++ head/sys/arm64/arm64/elf32_machdep.c
@@ -232,7 +232,7 @@
static void
freebsd32_setregs(struct thread *td, struct image_params *imgp,
- u_long stack)
+ uintptr_t stack)
{
struct trapframe *tf = td->td_frame;
Index: head/sys/arm64/arm64/machdep.c
===================================================================
--- head/sys/arm64/arm64/machdep.c
+++ head/sys/arm64/arm64/machdep.c
@@ -436,7 +436,7 @@
}
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;
Index: head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
===================================================================
--- head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
+++ head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
@@ -49,7 +49,7 @@
static void
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
- unsigned long stack)
+ uintptr_t stack)
{
struct trapframe *regs;
Index: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
===================================================================
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
@@ -49,7 +49,7 @@
static void
cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp,
- unsigned long stack)
+ uintptr_t stack)
{
struct trapframe *regs;
Index: head/sys/arm64/linux/linux_sysvec.c
===================================================================
--- head/sys/arm64/linux/linux_sysvec.c
+++ head/sys/arm64/linux/linux_sysvec.c
@@ -70,8 +70,8 @@
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_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 @@
}
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 @@
}
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 @@
* 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 @@
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 @@
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 @@
/* 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 @@
/* 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 @@
* 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;
Index: head/sys/compat/cloudabi32/cloudabi32_module.c
===================================================================
--- head/sys/compat/cloudabi32/cloudabi32_module.c
+++ head/sys/compat/cloudabi32/cloudabi32_module.c
@@ -46,7 +46,7 @@
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 @@
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 @@
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 @@
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 @@
#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);
}
Index: head/sys/compat/cloudabi32/cloudabi32_util.h
===================================================================
--- head/sys/compat/cloudabi32/cloudabi32_util.h
+++ head/sys/compat/cloudabi32/cloudabi32_util.h
@@ -42,8 +42,8 @@
#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);
Index: head/sys/compat/cloudabi64/cloudabi64_module.c
===================================================================
--- head/sys/compat/cloudabi64/cloudabi64_module.c
+++ head/sys/compat/cloudabi64/cloudabi64_module.c
@@ -46,7 +46,7 @@
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 @@
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 @@
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 @@
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 @@
#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);
}
Index: head/sys/compat/cloudabi64/cloudabi64_util.h
===================================================================
--- head/sys/compat/cloudabi64/cloudabi64_util.h
+++ head/sys/compat/cloudabi64/cloudabi64_util.h
@@ -42,8 +42,8 @@
#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);
Index: head/sys/compat/freebsd32/freebsd32_misc.c
===================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c
+++ head/sys/compat/freebsd32/freebsd32_misc.c
@@ -3120,12 +3120,12 @@
}
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 @@
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 @@
/*
* 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 @@
/*
* 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 @@
* 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 @@
* 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 */
Index: head/sys/compat/freebsd32/freebsd32_util.h
===================================================================
--- head/sys/compat/freebsd32/freebsd32_util.h
+++ head/sys/compat/freebsd32/freebsd32_util.h
@@ -113,7 +113,7 @@
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);
Index: head/sys/compat/ia32/ia32_signal.h
===================================================================
--- head/sys/compat/ia32/ia32_signal.h
+++ head/sys/compat/ia32/ia32_signal.h
@@ -206,7 +206,7 @@
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
Index: head/sys/i386/cloudabi32/cloudabi32_sysvec.c
===================================================================
--- head/sys/i386/cloudabi32/cloudabi32_sysvec.c
+++ head/sys/i386/cloudabi32/cloudabi32_sysvec.c
@@ -48,7 +48,7 @@
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 @@
* 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);
Index: head/sys/i386/i386/machdep.c
===================================================================
--- head/sys/i386/i386/machdep.c
+++ head/sys/i386/i386/machdep.c
@@ -1124,7 +1124,7 @@
* 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;
Index: head/sys/i386/linux/linux_sysvec.c
===================================================================
--- head/sys/i386/linux/linux_sysvec.c
+++ head/sys/i386/linux/linux_sysvec.c
@@ -88,15 +88,15 @@
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 @@
}
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 @@
}
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 @@
* 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 @@
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 @@
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 @@
/* 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 @@
/* 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 @@
* 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;
Index: head/sys/kern/imgact_aout.c
===================================================================
--- head/sys/kern/imgact_aout.c
+++ head/sys/kern/imgact_aout.c
@@ -65,7 +65,7 @@
#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 @@
#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
Index: head/sys/kern/imgact_elf.c
===================================================================
--- head/sys/kern/imgact_elf.c
+++ head/sys/kern/imgact_elf.c
@@ -1324,7 +1324,7 @@
#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 @@
}
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 @@
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 @@
}
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)
Index: head/sys/kern/kern_exec.c
===================================================================
--- head/sys/kern/kern_exec.c
+++ head/sys/kern/kern_exec.c
@@ -360,7 +360,7 @@
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 @@
#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 @@
* 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 @@
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 @@
/*
* 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 @@
/*
* 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 @@
* 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 @@
* 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 */
Index: head/sys/mips/mips/freebsd32_machdep.c
===================================================================
--- head/sys/mips/mips/freebsd32_machdep.c
+++ head/sys/mips/mips/freebsd32_machdep.c
@@ -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 @@
&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);
Index: head/sys/mips/mips/pm_machdep.c
===================================================================
--- head/sys/mips/mips/pm_machdep.c
+++ head/sys/mips/mips/pm_machdep.c
@@ -410,7 +410,7 @@
* 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));
Index: head/sys/powerpc/include/reg.h
===================================================================
--- head/sys/powerpc/include/reg.h
+++ head/sys/powerpc/include/reg.h
@@ -73,7 +73,7 @@
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)
Index: head/sys/powerpc/powerpc/elf64_machdep.c
===================================================================
--- head/sys/powerpc/powerpc/elf64_machdep.c
+++ head/sys/powerpc/powerpc/elf64_machdep.c
@@ -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 @@
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];
Index: head/sys/powerpc/powerpc/exec_machdep.c
===================================================================
--- head/sys/powerpc/powerpc/exec_machdep.c
+++ head/sys/powerpc/powerpc/exec_machdep.c
@@ -539,7 +539,7 @@
* 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 @@
#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;
Index: head/sys/riscv/riscv/machdep.c
===================================================================
--- head/sys/riscv/riscv/machdep.c
+++ head/sys/riscv/riscv/machdep.c
@@ -297,7 +297,7 @@
}
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;
Index: head/sys/sparc64/sparc64/machdep.c
===================================================================
--- head/sys/sparc64/sparc64/machdep.c
+++ head/sys/sparc64/sparc64/machdep.c
@@ -978,12 +978,12 @@
}
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;
Index: head/sys/sys/imgact.h
===================================================================
--- head/sys/sys/imgact.h
+++ head/sys/sys/imgact.h
@@ -110,10 +110,10 @@
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 **);
Index: head/sys/sys/imgact_elf.h
===================================================================
--- head/sys/sys/imgact_elf.h
+++ head/sys/sys/imgact_elf.h
@@ -95,11 +95,11 @@
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 *);
Index: head/sys/sys/sysent.h
===================================================================
--- head/sys/sys/sysent.h
+++ head/sys/sys/sysent.h
@@ -99,7 +99,7 @@
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 @@
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;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 23, 2:06 AM (59 m, 47 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16785536
Default Alt Text
D22501.diff (50 KB)
Attached To
Mode
D22501: Use uintptr_t instead of register_t * for the stack base.
Attached
Detach File
Event Timeline
Log In to Comment