Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F132964251
D15123.id41603.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D15123.id41603.diff
View Options
Index: sys/amd64/linux/linux_sysvec.c
===================================================================
--- sys/amd64/linux/linux_sysvec.c
+++ sys/amd64/linux/linux_sysvec.c
@@ -338,32 +338,22 @@
roundup(sizeof(canary), sizeof(char *));
copyout(canary, (void *)imgp->canary, sizeof(canary));
- /* If we have a valid auxargs ptr, prepare some room on the stack. */
+ vectp = (char **)destp;
if (imgp->auxargs) {
/*
- * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
- * lower compatibility.
+ * Allocate room on the stack for the ELF auxargs
+ * array. It has LINUX_AT_COUNT entries.
*/
- imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size :
- (LINUX_AT_COUNT * 2);
-
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets,and imgp->auxarg_size is room
- * for argument of Runtime loader.
- */
- vectp = (char **)(destp - (imgp->args->argc +
- imgp->args->envc + 2 + imgp->auxarg_size) * sizeof(char *));
-
- } else {
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets
- */
- vectp = (char **)(destp - (imgp->args->argc +
- imgp->args->envc + 2) * sizeof(char *));
+ vectp = (char **)((char *)vectp - LINUX_AT_COUNT *
+ sizeof(Elf_Auxinfo));
}
+ /*
+ * Allocate room for the argv[] and env vectors including the
+ * terminating NULL pointers.
+ */
+ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
+
/* vectp also becomes our initial stack base. */
stack_base = (register_t *)vectp;
Index: sys/amd64/linux32/linux32_sysvec.c
===================================================================
--- sys/amd64/linux32/linux32_sysvec.c
+++ sys/amd64/linux32/linux32_sysvec.c
@@ -831,30 +831,21 @@
roundup(sizeof(canary), sizeof(char *));
copyout(canary, (void *)imgp->canary, sizeof(canary));
- /* If we have a valid auxargs ptr, prepare some room on the stack. */
+ vectp = (uint32_t *)destp;
if (imgp->auxargs) {
/*
- * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
- * lower compatibility.
+ * Allocate room on the stack for the ELF auxargs
+ * array. It has LINUX_AT_COUNT entries.
*/
- imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size :
- (LINUX_AT_COUNT * 2);
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets,and imgp->auxarg_size is room
- * for argument of Runtime loader.
- */
- vectp = (u_int32_t *) (destp - (imgp->args->argc +
- imgp->args->envc + 2 + imgp->auxarg_size) *
- sizeof(u_int32_t));
+ vectp = (uint32_t *)((char *)vectp - LINUX_AT_COUNT *
+ sizeof(Elf32_Auxinfo));
+ }
- } else
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets
- */
- vectp = (u_int32_t *)(destp - (imgp->args->argc +
- imgp->args->envc + 2) * sizeof(u_int32_t));
+ /*
+ * Allocate room for the argv[] and env vectors including the
+ * terminating NULL pointers.
+ */
+ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
/* vectp also becomes our initial stack base. */
stack_base = vectp;
Index: sys/compat/freebsd32/freebsd32_misc.c
===================================================================
--- sys/compat/freebsd32/freebsd32_misc.c
+++ sys/compat/freebsd32/freebsd32_misc.c
@@ -3180,34 +3180,22 @@
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(uint32_t));
- /*
- * If we have a valid auxargs ptr, prepare some room
- * on the stack.
- */
+ vectp = (uint32_t *)destp;
if (imgp->auxargs) {
/*
- * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
- * lower compatibility.
- */
- imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size
- : (AT_COUNT * 2);
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets,and imgp->auxarg_size is room
- * for argument of Runtime loader.
- */
- vectp = (u_int32_t *) (destp - (imgp->args->argc +
- imgp->args->envc + 2 + imgp->auxarg_size + execpath_len) *
- sizeof(u_int32_t));
- } else {
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets
+ * Allocate room on the stack for the ELF auxargs
+ * array. It has up to AT_COUNT entries.
*/
- vectp = (u_int32_t *)(destp - (imgp->args->argc +
- imgp->args->envc + 2) * sizeof(u_int32_t));
+ vectp = (uint32_t *)((char *)vectp - AT_COUNT *
+ sizeof(Elf32_Auxinfo));
}
+ /*
+ * Allocate room for the argv[] and env vectors including the
+ * terminating NULL pointers.
+ */
+ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
+
/*
* vectp also becomes our initial stack base
*/
Index: sys/i386/linux/linux_sysvec.c
===================================================================
--- sys/i386/linux/linux_sysvec.c
+++ sys/i386/linux/linux_sysvec.c
@@ -316,30 +316,22 @@
roundup(sizeof(canary), sizeof(char *));
copyout(canary, (void *)imgp->canary, sizeof(canary));
- /* If we have a valid auxargs ptr, prepare some room on the stack. */
+ vectp = (char **)destp;
if (imgp->auxargs) {
/*
- * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
- * lower compatibility.
+ * Allocate room on the stack for the ELF auxargs
+ * array. It has LINUX_AT_COUNT entries.
*/
- imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size :
- (LINUX_AT_COUNT * 2);
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets,and imgp->auxarg_size is room
- * for argument of Runtime loader.
- */
- vectp = (char **)(destp - (imgp->args->argc +
- imgp->args->envc + 2 + imgp->auxarg_size) * sizeof(char *));
- } else {
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets
- */
- vectp = (char **)(destp - (imgp->args->argc + imgp->args->envc + 2) *
- sizeof(char *));
+ vectp = (char **)((char *)vectp - LINUX_AT_COUNT *
+ sizeof(Elf_Auxinfo));
}
+ /*
+ * Allocate room for the argv[] and env vectors including the
+ * terminating NULL pointers.
+ */
+ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
+
/* vectp also becomes our initial stack base. */
stack_base = (register_t *)vectp;
Index: sys/kern/kern_exec.c
===================================================================
--- sys/kern/kern_exec.c
+++ sys/kern/kern_exec.c
@@ -1533,34 +1533,22 @@
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(void *));
- /*
- * If we have a valid auxargs ptr, prepare some room
- * on the stack.
- */
+ vectp = (char **)destp;
if (imgp->auxargs) {
/*
- * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
- * lower compatibility.
- */
- imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size :
- (AT_COUNT * 2);
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets,and imgp->auxarg_size is room
- * for argument of Runtime loader.
- */
- vectp = (char **)(destp - (imgp->args->argc +
- imgp->args->envc + 2 + imgp->auxarg_size)
- * sizeof(char *));
- } else {
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets
+ * Allocate room on the stack for the ELF auxargs
+ * array. It has up to AT_COUNT entries.
*/
- vectp = (char **)(destp - (imgp->args->argc + imgp->args->envc
- + 2) * sizeof(char *));
+ vectp = (char **)((char *)vectp - AT_COUNT *
+ sizeof(Elf_Auxinfo));
}
+ /*
+ * Allocate room for the argv[] and env vectors including the
+ * terminating NULL pointers.
+ */
+ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
+
/*
* vectp also becomes our initial stack base
*/
Index: sys/sys/imgact.h
===================================================================
--- sys/sys/imgact.h
+++ sys/sys/imgact.h
@@ -75,7 +75,6 @@
void *auxargs; /* ELF Auxinfo structure pointer */
struct sf_buf *firstpage; /* first page that we mapped */
unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */
- size_t auxarg_size;
struct image_args *args; /* system call arguments */
struct sysentvec *sysent; /* system entry vector */
char *execpath;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 22, 2:57 PM (12 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24058742
Default Alt Text
D15123.id41603.diff (8 KB)
Attached To
Mode
D15123: Simplify the code to allocate stack for auxv, argv[], and environment vectors.
Attached
Detach File
Event Timeline
Log In to Comment