summaryrefslogtreecommitdiffstats
path: root/sys/compat/freebsd32
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-08-17 08:55:45 +0000
committerkib <kib@FreeBSD.org>2010-08-17 08:55:45 +0000
commitd9f088a03e65b9a9a1109213406f79fc4a1b33ae (patch)
tree33205433846af6fcb0274947c72e1f1e9432d3fe /sys/compat/freebsd32
parent407c718f42064fc833ef52171e7d791d793f2b5f (diff)
downloadFreeBSD-src-d9f088a03e65b9a9a1109213406f79fc4a1b33ae.zip
FreeBSD-src-d9f088a03e65b9a9a1109213406f79fc4a1b33ae.tar.gz
Supply some useful information to the started image using ELF aux vectors.
In particular, provide pagesize and pagesizes array, the canary value for SSP use, number of host CPUs and osreldate. Tested by: marius (sparc64) MFC after: 1 month
Diffstat (limited to 'sys/compat/freebsd32')
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 579d81b..8da3833 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -2525,11 +2525,13 @@ syscall32_helper_unregister(struct syscall_helper_data *sd)
register_t *
freebsd32_copyout_strings(struct image_params *imgp)
{
- int argc, envc;
+ int argc, envc, i;
u_int32_t *vectp;
char *stringp, *destp;
u_int32_t *stack_base;
struct freebsd32_ps_strings *arginfo;
+ char canary[sizeof(long) * 8];
+ int32_t pagesizes32[MAXPAGESIZES];
size_t execpath_len;
int szsigcode;
@@ -2545,8 +2547,10 @@ freebsd32_copyout_strings(struct image_params *imgp)
sv_psstrings;
szsigcode = *(imgp->proc->p_sysent->sv_szsigcode);
destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE -
- roundup(execpath_len, sizeof(char *)) -
- roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *));
+ roundup(execpath_len, sizeof(char *)) -
+ roundup(sizeof(canary), sizeof(char *)) -
+ roundup(sizeof(pagesizes32), sizeof(char *)) -
+ roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *));
/*
* install sigcode
@@ -2565,6 +2569,25 @@ freebsd32_copyout_strings(struct image_params *imgp)
}
/*
+ * Prepare the canary for SSP.
+ */
+ arc4rand(canary, sizeof(canary), 0);
+ imgp->canary = (uintptr_t)arginfo - szsigcode - execpath_len -
+ sizeof(canary);
+ copyout(canary, (void *)imgp->canary, sizeof(canary));
+ imgp->canarylen = sizeof(canary);
+
+ /*
+ * Prepare the pagesizes array.
+ */
+ for (i = 0; i < MAXPAGESIZES; i++)
+ pagesizes32[i] = (uint32_t)pagesizes[i];
+ imgp->pagesizes = (uintptr_t)arginfo - szsigcode - execpath_len -
+ roundup(sizeof(canary), sizeof(char *)) - sizeof(pagesizes32);
+ copyout(pagesizes32, (void *)imgp->pagesizes, sizeof(pagesizes32));
+ imgp->pagesizeslen = sizeof(pagesizes32);
+
+ /*
* If we have a valid auxargs ptr, prepare some room
* on the stack.
*/
OpenPOWER on IntegriCloud