Convert canary, execpathp, and pagesizes to pointers.
Use AUXARGS_ENTRY_PTR to export these pointers. This is a followup to r359987 and r359988. Reviewed by: jhb Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24446
This commit is contained in:
parent
0e8009c97b
commit
92f82df12b
@ -254,9 +254,9 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
||||
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||
if (imgp->execpathp != 0)
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
||||
if (args->execfd != -1)
|
||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
||||
@ -315,8 +315,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
if (execpath_len != 0) {
|
||||
destp -= execpath_len;
|
||||
destp = rounddown2(destp, sizeof(void *));
|
||||
imgp->execpathp = destp;
|
||||
error = copyout(imgp->execpath, (void *)destp, execpath_len);
|
||||
imgp->execpathp = (void *)destp;
|
||||
error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
@ -324,8 +324,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
/* Prepare the canary for SSP. */
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
destp -= roundup(sizeof(canary), sizeof(void *));
|
||||
imgp->canary = destp;
|
||||
error = copyout(canary, (void *)destp, sizeof(canary));
|
||||
imgp->canary = (void *)destp;
|
||||
error = copyout(canary, imgp->canary, sizeof(canary));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
|
@ -742,8 +742,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
if (execpath_len != 0) {
|
||||
destp -= execpath_len;
|
||||
destp = rounddown2(destp, sizeof(uint32_t));
|
||||
imgp->execpathp = destp;
|
||||
error = copyout(imgp->execpath, (void *)destp, execpath_len);
|
||||
imgp->execpathp = (void *)destp;
|
||||
error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
@ -751,8 +751,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
/* Prepare the canary for SSP. */
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
destp -= roundup(sizeof(canary), sizeof(uint32_t));
|
||||
imgp->canary = destp;
|
||||
error = copyout(canary, (void *)destp, sizeof(canary));
|
||||
imgp->canary = (void *)destp;
|
||||
error = copyout(canary, imgp->canary, sizeof(canary));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
|
@ -180,9 +180,9 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
||||
#if 0 /* LINUXTODO: implement arm64 LINUX_AT_PLATFORM */
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||
#endif
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||
if (imgp->execpathp != 0)
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
||||
if (args->execfd != -1)
|
||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
||||
@ -236,8 +236,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
if (execpath_len != 0) {
|
||||
destp -= execpath_len;
|
||||
destp = rounddown2(destp, sizeof(void *));
|
||||
imgp->execpathp = destp;
|
||||
error = copyout(imgp->execpath, (void *)destp, execpath_len);
|
||||
imgp->execpathp = (void *)destp;
|
||||
error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
@ -245,8 +245,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
/* Prepare the canary for SSP. */
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
destp -= roundup(sizeof(canary), sizeof(void *));
|
||||
imgp->canary = destp;
|
||||
error = copyout(canary, (void *)destp, sizeof(canary));
|
||||
imgp->canary = (void *)destp;
|
||||
error = copyout(canary, imgp->canary, sizeof(canary));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
|
@ -3161,8 +3161,8 @@ freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
*/
|
||||
if (execpath_len != 0) {
|
||||
destp -= execpath_len;
|
||||
imgp->execpathp = destp;
|
||||
error = copyout(imgp->execpath, (void *)destp, execpath_len);
|
||||
imgp->execpathp = (void *)destp;
|
||||
error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
@ -3172,8 +3172,8 @@ freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
*/
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
destp -= sizeof(canary);
|
||||
imgp->canary = destp;
|
||||
error = copyout(canary, (void *)destp, sizeof(canary));
|
||||
imgp->canary = (void *)destp;
|
||||
error = copyout(canary, imgp->canary, sizeof(canary));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
imgp->canarylen = sizeof(canary);
|
||||
@ -3185,8 +3185,8 @@ freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
pagesizes32[i] = (uint32_t)pagesizes[i];
|
||||
destp -= sizeof(pagesizes32);
|
||||
destp = rounddown2(destp, sizeof(uint32_t));
|
||||
imgp->pagesizes = destp;
|
||||
error = copyout(pagesizes32, (void *)destp, sizeof(pagesizes32));
|
||||
imgp->pagesizes = (void *)destp;
|
||||
error = copyout(pagesizes32, imgp->pagesizes, sizeof(pagesizes32));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
imgp->pagesizeslen = sizeof(pagesizes32);
|
||||
|
@ -237,9 +237,9 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
||||
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
|
||||
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(uplatform));
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||
if (imgp->execpathp != 0)
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
||||
if (args->execfd != -1)
|
||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
||||
@ -301,8 +301,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
if (execpath_len != 0) {
|
||||
destp -= execpath_len;
|
||||
destp = rounddown2(destp, sizeof(void *));
|
||||
imgp->execpathp = destp;
|
||||
error = copyout(imgp->execpath, (void *)destp, execpath_len);
|
||||
imgp->execpathp = (void *)destp;
|
||||
error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
@ -310,8 +310,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
/* Prepare the canary for SSP. */
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
destp -= roundup(sizeof(canary), sizeof(void *));
|
||||
imgp->canary = destp;
|
||||
error = copyout(canary, (void *)destp, sizeof(canary));
|
||||
imgp->canary = (void *)destp;
|
||||
error = copyout(canary, imgp->canary, sizeof(canary));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
|
@ -1349,16 +1349,16 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base)
|
||||
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
||||
AUXARGS_ENTRY(pos, AT_EHDRFLAGS, args->hdr_eflags);
|
||||
if (imgp->execpathp != 0)
|
||||
AUXARGS_ENTRY(pos, AT_EXECPATH, imgp->execpathp);
|
||||
AUXARGS_ENTRY_PTR(pos, AT_EXECPATH, imgp->execpathp);
|
||||
AUXARGS_ENTRY(pos, AT_OSRELDATE,
|
||||
imgp->proc->p_ucred->cr_prison->pr_osreldate);
|
||||
if (imgp->canary != 0) {
|
||||
AUXARGS_ENTRY(pos, AT_CANARY, imgp->canary);
|
||||
AUXARGS_ENTRY_PTR(pos, AT_CANARY, imgp->canary);
|
||||
AUXARGS_ENTRY(pos, AT_CANARYLEN, imgp->canarylen);
|
||||
}
|
||||
AUXARGS_ENTRY(pos, AT_NCPUS, mp_ncpus);
|
||||
if (imgp->pagesizes != 0) {
|
||||
AUXARGS_ENTRY(pos, AT_PAGESIZES, imgp->pagesizes);
|
||||
AUXARGS_ENTRY_PTR(pos, AT_PAGESIZES, imgp->pagesizes);
|
||||
AUXARGS_ENTRY(pos, AT_PAGESIZESLEN, imgp->pagesizeslen);
|
||||
}
|
||||
if (imgp->sysent->sv_timekeep_base != 0) {
|
||||
|
@ -1571,8 +1571,8 @@ exec_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
if (execpath_len != 0) {
|
||||
destp -= execpath_len;
|
||||
destp = rounddown2(destp, sizeof(void *));
|
||||
imgp->execpathp = destp;
|
||||
error = copyout(imgp->execpath, (void *)destp, execpath_len);
|
||||
imgp->execpathp = (void *)destp;
|
||||
error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
@ -1582,8 +1582,8 @@ exec_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
*/
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
destp -= sizeof(canary);
|
||||
imgp->canary = destp;
|
||||
error = copyout(canary, (void *)destp, sizeof(canary));
|
||||
imgp->canary = (void *)destp;
|
||||
error = copyout(canary, imgp->canary, sizeof(canary));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
imgp->canarylen = sizeof(canary);
|
||||
@ -1593,8 +1593,8 @@ exec_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
|
||||
*/
|
||||
destp -= szps;
|
||||
destp = rounddown2(destp, sizeof(void *));
|
||||
imgp->pagesizes = destp;
|
||||
error = copyout(pagesizes, (void *)destp, szps);
|
||||
imgp->pagesizes = (void *)destp;
|
||||
error = copyout(pagesizes, imgp->pagesizes, szps);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
imgp->pagesizeslen = szps;
|
||||
|
@ -54,16 +54,16 @@ __elfN(powerpc_copyout_auxargs)(struct image_params *imgp, uintptr_t base)
|
||||
AUXARGS_ENTRY(pos, AT_OLD_BASE, args->base);
|
||||
AUXARGS_ENTRY(pos, AT_OLD_EHDRFLAGS, args->hdr_eflags);
|
||||
if (imgp->execpathp != 0)
|
||||
AUXARGS_ENTRY(pos, AT_OLD_EXECPATH, imgp->execpathp);
|
||||
AUXARGS_ENTRY_PTR(pos, AT_OLD_EXECPATH, imgp->execpathp);
|
||||
AUXARGS_ENTRY(pos, AT_OLD_OSRELDATE,
|
||||
imgp->proc->p_ucred->cr_prison->pr_osreldate);
|
||||
if (imgp->canary != 0) {
|
||||
AUXARGS_ENTRY(pos, AT_OLD_CANARY, imgp->canary);
|
||||
AUXARGS_ENTRY_PTR(pos, AT_OLD_CANARY, imgp->canary);
|
||||
AUXARGS_ENTRY(pos, AT_OLD_CANARYLEN, imgp->canarylen);
|
||||
}
|
||||
AUXARGS_ENTRY(pos, AT_OLD_NCPUS, mp_ncpus);
|
||||
if (imgp->pagesizes != 0) {
|
||||
AUXARGS_ENTRY(pos, AT_OLD_PAGESIZES, imgp->pagesizes);
|
||||
AUXARGS_ENTRY_PTR(pos, AT_OLD_PAGESIZES, imgp->pagesizes);
|
||||
AUXARGS_ENTRY(pos, AT_OLD_PAGESIZESLEN, imgp->pagesizeslen);
|
||||
}
|
||||
if (imgp->sysent->sv_timekeep_base != 0) {
|
||||
|
@ -81,11 +81,11 @@ struct image_params {
|
||||
void *argv; /* pointer to argv (user space) */
|
||||
void *envv; /* pointer to envv (user space) */
|
||||
char *execpath;
|
||||
unsigned long execpathp;
|
||||
void *execpathp;
|
||||
char *freepath;
|
||||
unsigned long canary;
|
||||
void *canary;
|
||||
int canarylen;
|
||||
unsigned long pagesizes;
|
||||
void *pagesizes;
|
||||
int pagesizeslen;
|
||||
vm_prot_t stack_prot;
|
||||
u_long stack_sz;
|
||||
|
Loading…
Reference in New Issue
Block a user