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:
Brooks Davis 2020-04-16 21:53:17 +00:00
parent d3920c5b12
commit b24e6ac8b7
9 changed files with 43 additions and 43 deletions

View File

@ -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, AT_EGID, imgp->proc->p_ucred->cr_svgid);
AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid); AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform)); 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) 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) if (args->execfd != -1)
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
AUXARGS_ENTRY(pos, AT_NULL, 0); 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) { if (execpath_len != 0) {
destp -= execpath_len; destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *)); destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp; imgp->execpathp = (void *)destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len); error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -324,8 +324,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
/* Prepare the canary for SSP. */ /* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0); arc4rand(canary, sizeof(canary), 0);
destp -= roundup(sizeof(canary), sizeof(void *)); destp -= roundup(sizeof(canary), sizeof(void *));
imgp->canary = destp; imgp->canary = (void *)destp;
error = copyout(canary, (void *)destp, sizeof(canary)); error = copyout(canary, imgp->canary, sizeof(canary));
if (error != 0) if (error != 0)
return (error); return (error);

View File

@ -742,8 +742,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
if (execpath_len != 0) { if (execpath_len != 0) {
destp -= execpath_len; destp -= execpath_len;
destp = rounddown2(destp, sizeof(uint32_t)); destp = rounddown2(destp, sizeof(uint32_t));
imgp->execpathp = destp; imgp->execpathp = (void *)destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len); error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -751,8 +751,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
/* Prepare the canary for SSP. */ /* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0); arc4rand(canary, sizeof(canary), 0);
destp -= roundup(sizeof(canary), sizeof(uint32_t)); destp -= roundup(sizeof(canary), sizeof(uint32_t));
imgp->canary = destp; imgp->canary = (void *)destp;
error = copyout(canary, (void *)destp, sizeof(canary)); error = copyout(canary, imgp->canary, sizeof(canary));
if (error != 0) if (error != 0)
return (error); return (error);

View File

@ -180,9 +180,9 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
#if 0 /* LINUXTODO: implement arm64 LINUX_AT_PLATFORM */ #if 0 /* LINUXTODO: implement arm64 LINUX_AT_PLATFORM */
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform)); AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
#endif #endif
AUXARGS_ENTRY(pos, LINUX_AT_RANDOM, imgp->canary); AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
if (imgp->execpathp != 0) 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) if (args->execfd != -1)
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
AUXARGS_ENTRY(pos, AT_NULL, 0); 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) { if (execpath_len != 0) {
destp -= execpath_len; destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *)); destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp; imgp->execpathp = (void *)destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len); error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -245,8 +245,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
/* Prepare the canary for SSP. */ /* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0); arc4rand(canary, sizeof(canary), 0);
destp -= roundup(sizeof(canary), sizeof(void *)); destp -= roundup(sizeof(canary), sizeof(void *));
imgp->canary = destp; imgp->canary = (void *)destp;
error = copyout(canary, (void *)destp, sizeof(canary)); error = copyout(canary, imgp->canary, sizeof(canary));
if (error != 0) if (error != 0)
return (error); return (error);

View File

@ -3161,8 +3161,8 @@ freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
*/ */
if (execpath_len != 0) { if (execpath_len != 0) {
destp -= execpath_len; destp -= execpath_len;
imgp->execpathp = destp; imgp->execpathp = (void *)destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len); error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -3172,8 +3172,8 @@ freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
*/ */
arc4rand(canary, sizeof(canary), 0); arc4rand(canary, sizeof(canary), 0);
destp -= sizeof(canary); destp -= sizeof(canary);
imgp->canary = destp; imgp->canary = (void *)destp;
error = copyout(canary, (void *)destp, sizeof(canary)); error = copyout(canary, imgp->canary, sizeof(canary));
if (error != 0) if (error != 0)
return (error); return (error);
imgp->canarylen = sizeof(canary); 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]; pagesizes32[i] = (uint32_t)pagesizes[i];
destp -= sizeof(pagesizes32); destp -= sizeof(pagesizes32);
destp = rounddown2(destp, sizeof(uint32_t)); destp = rounddown2(destp, sizeof(uint32_t));
imgp->pagesizes = destp; imgp->pagesizes = (void *)destp;
error = copyout(pagesizes32, (void *)destp, sizeof(pagesizes32)); error = copyout(pagesizes32, imgp->pagesizes, sizeof(pagesizes32));
if (error != 0) if (error != 0)
return (error); return (error);
imgp->pagesizeslen = sizeof(pagesizes32); imgp->pagesizeslen = sizeof(pagesizes32);

View File

@ -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_GID, imgp->proc->p_ucred->cr_rgid);
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid); AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(uplatform)); 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) 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) if (args->execfd != -1)
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
AUXARGS_ENTRY(pos, AT_NULL, 0); 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) { if (execpath_len != 0) {
destp -= execpath_len; destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *)); destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp; imgp->execpathp = (void *)destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len); error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -310,8 +310,8 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
/* Prepare the canary for SSP. */ /* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0); arc4rand(canary, sizeof(canary), 0);
destp -= roundup(sizeof(canary), sizeof(void *)); destp -= roundup(sizeof(canary), sizeof(void *));
imgp->canary = destp; imgp->canary = (void *)destp;
error = copyout(canary, (void *)destp, sizeof(canary)); error = copyout(canary, imgp->canary, sizeof(canary));
if (error != 0) if (error != 0)
return (error); return (error);

View File

@ -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_BASE, args->base);
AUXARGS_ENTRY(pos, AT_EHDRFLAGS, args->hdr_eflags); AUXARGS_ENTRY(pos, AT_EHDRFLAGS, args->hdr_eflags);
if (imgp->execpathp != 0) if (imgp->execpathp != 0)
AUXARGS_ENTRY(pos, AT_EXECPATH, imgp->execpathp); AUXARGS_ENTRY_PTR(pos, AT_EXECPATH, imgp->execpathp);
AUXARGS_ENTRY(pos, AT_OSRELDATE, AUXARGS_ENTRY(pos, AT_OSRELDATE,
imgp->proc->p_ucred->cr_prison->pr_osreldate); imgp->proc->p_ucred->cr_prison->pr_osreldate);
if (imgp->canary != 0) { 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_CANARYLEN, imgp->canarylen);
} }
AUXARGS_ENTRY(pos, AT_NCPUS, mp_ncpus); AUXARGS_ENTRY(pos, AT_NCPUS, mp_ncpus);
if (imgp->pagesizes != 0) { 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); AUXARGS_ENTRY(pos, AT_PAGESIZESLEN, imgp->pagesizeslen);
} }
if (imgp->sysent->sv_timekeep_base != 0) { if (imgp->sysent->sv_timekeep_base != 0) {

View File

@ -1571,8 +1571,8 @@ exec_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
if (execpath_len != 0) { if (execpath_len != 0) {
destp -= execpath_len; destp -= execpath_len;
destp = rounddown2(destp, sizeof(void *)); destp = rounddown2(destp, sizeof(void *));
imgp->execpathp = destp; imgp->execpathp = (void *)destp;
error = copyout(imgp->execpath, (void *)destp, execpath_len); error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
if (error != 0) if (error != 0)
return (error); return (error);
} }
@ -1582,8 +1582,8 @@ exec_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
*/ */
arc4rand(canary, sizeof(canary), 0); arc4rand(canary, sizeof(canary), 0);
destp -= sizeof(canary); destp -= sizeof(canary);
imgp->canary = destp; imgp->canary = (void *)destp;
error = copyout(canary, (void *)destp, sizeof(canary)); error = copyout(canary, imgp->canary, sizeof(canary));
if (error != 0) if (error != 0)
return (error); return (error);
imgp->canarylen = sizeof(canary); imgp->canarylen = sizeof(canary);
@ -1593,8 +1593,8 @@ exec_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
*/ */
destp -= szps; destp -= szps;
destp = rounddown2(destp, sizeof(void *)); destp = rounddown2(destp, sizeof(void *));
imgp->pagesizes = destp; imgp->pagesizes = (void *)destp;
error = copyout(pagesizes, (void *)destp, szps); error = copyout(pagesizes, imgp->pagesizes, szps);
if (error != 0) if (error != 0)
return (error); return (error);
imgp->pagesizeslen = szps; imgp->pagesizeslen = szps;

View File

@ -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_BASE, args->base);
AUXARGS_ENTRY(pos, AT_OLD_EHDRFLAGS, args->hdr_eflags); AUXARGS_ENTRY(pos, AT_OLD_EHDRFLAGS, args->hdr_eflags);
if (imgp->execpathp != 0) 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, AUXARGS_ENTRY(pos, AT_OLD_OSRELDATE,
imgp->proc->p_ucred->cr_prison->pr_osreldate); imgp->proc->p_ucred->cr_prison->pr_osreldate);
if (imgp->canary != 0) { 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_CANARYLEN, imgp->canarylen);
} }
AUXARGS_ENTRY(pos, AT_OLD_NCPUS, mp_ncpus); AUXARGS_ENTRY(pos, AT_OLD_NCPUS, mp_ncpus);
if (imgp->pagesizes != 0) { 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); AUXARGS_ENTRY(pos, AT_OLD_PAGESIZESLEN, imgp->pagesizeslen);
} }
if (imgp->sysent->sv_timekeep_base != 0) { if (imgp->sysent->sv_timekeep_base != 0) {

View File

@ -81,11 +81,11 @@ struct image_params {
void *argv; /* pointer to argv (user space) */ void *argv; /* pointer to argv (user space) */
void *envv; /* pointer to envv (user space) */ void *envv; /* pointer to envv (user space) */
char *execpath; char *execpath;
unsigned long execpathp; void *execpathp;
char *freepath; char *freepath;
unsigned long canary; void *canary;
int canarylen; int canarylen;
unsigned long pagesizes; void *pagesizes;
int pagesizeslen; int pagesizeslen;
vm_prot_t stack_prot; vm_prot_t stack_prot;
u_long stack_sz; u_long stack_sz;