linux(4): Deduplicate linux_copyout_auxargs()
Export default MINSIGSTKSZ value for the x86 until we do not preserve AVX registers in the signal context. Differential Revision: https://reviews.freebsd.org/D39644 MFC after: 1 month
This commit is contained in:
parent
8561d0b2ec
commit
7d8c983983
@ -90,7 +90,7 @@ typedef struct {
|
|||||||
/*
|
/*
|
||||||
* Miscellaneous
|
* Miscellaneous
|
||||||
*/
|
*/
|
||||||
#define LINUX_AT_COUNT 20 /* Count of used aux entry types. */
|
#define LINUX_AT_COUNT 21 /* Count of used aux entry types. */
|
||||||
|
|
||||||
struct l___sysctl_args
|
struct l___sysctl_args
|
||||||
{
|
{
|
||||||
|
@ -207,52 +207,14 @@ linux_set_fork_retval(struct thread *td)
|
|||||||
frame->tf_rax = 0;
|
frame->tf_rax = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
void
|
||||||
linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
linux64_arch_copyout_auxargs(struct image_params *imgp, Elf_Auxinfo **pos)
|
||||||
{
|
{
|
||||||
Elf_Auxargs *args;
|
|
||||||
Elf_Auxinfo *argarray, *pos;
|
|
||||||
struct proc *p;
|
|
||||||
int error, issetugid;
|
|
||||||
|
|
||||||
p = imgp->proc;
|
AUXARGS_ENTRY((*pos), LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
||||||
args = (Elf64_Auxargs *)imgp->auxargs;
|
AUXARGS_ENTRY((*pos), LINUX_AT_HWCAP, cpu_feature);
|
||||||
argarray = pos = malloc(LINUX_AT_COUNT * sizeof(*pos), M_TEMP,
|
AUXARGS_ENTRY((*pos), LINUX_AT_HWCAP2, 0);
|
||||||
M_WAITOK | M_ZERO);
|
AUXARGS_ENTRY((*pos), LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||||
|
|
||||||
issetugid = p->p_flag & P_SUGID ? 1 : 0;
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
|
||||||
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
|
||||||
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
|
||||||
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
|
||||||
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
|
||||||
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
|
||||||
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_SECURE, issetugid);
|
|
||||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP2, 0);
|
|
||||||
if (imgp->execpathp != 0)
|
|
||||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
|
||||||
if (args->execfd != -1)
|
|
||||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
|
||||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
|
||||||
|
|
||||||
free(imgp->auxargs, M_TEMP);
|
|
||||||
imgp->auxargs = NULL;
|
|
||||||
KASSERT(pos - argarray <= LINUX_AT_COUNT, ("Too many auxargs"));
|
|
||||||
|
|
||||||
error = copyout(argarray, (void *)base,
|
|
||||||
sizeof(*argarray) * LINUX_AT_COUNT);
|
|
||||||
free(argarray, M_TEMP);
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -623,7 +585,7 @@ struct sysentvec elf_linux_sysvec = {
|
|||||||
.sv_psstrings = LINUX_PS_STRINGS_LA48,
|
.sv_psstrings = LINUX_PS_STRINGS_LA48,
|
||||||
.sv_psstringssz = sizeof(struct ps_strings),
|
.sv_psstringssz = sizeof(struct ps_strings),
|
||||||
.sv_stackprot = VM_PROT_ALL,
|
.sv_stackprot = VM_PROT_ALL,
|
||||||
.sv_copyout_auxargs = linux_copyout_auxargs,
|
.sv_copyout_auxargs = __linuxN(copyout_auxargs),
|
||||||
.sv_copyout_strings = __linuxN(copyout_strings),
|
.sv_copyout_strings = __linuxN(copyout_strings),
|
||||||
.sv_setregs = linux_exec_setregs,
|
.sv_setregs = linux_exec_setregs,
|
||||||
.sv_fixlimit = NULL,
|
.sv_fixlimit = NULL,
|
||||||
@ -638,6 +600,8 @@ struct sysentvec elf_linux_sysvec = {
|
|||||||
.sv_schedtail = linux_schedtail,
|
.sv_schedtail = linux_schedtail,
|
||||||
.sv_thread_detach = linux_thread_detach,
|
.sv_thread_detach = linux_thread_detach,
|
||||||
.sv_trap = linux_vsyscall,
|
.sv_trap = linux_vsyscall,
|
||||||
|
.sv_hwcap = NULL,
|
||||||
|
.sv_hwcap2 = NULL,
|
||||||
.sv_onexec = linux_on_exec_vmspace,
|
.sv_onexec = linux_on_exec_vmspace,
|
||||||
.sv_onexit = linux_on_exit,
|
.sv_onexit = linux_on_exit,
|
||||||
.sv_ontdexit = linux_thread_dtor,
|
.sv_ontdexit = linux_thread_dtor,
|
||||||
|
@ -103,7 +103,7 @@ typedef struct {
|
|||||||
/*
|
/*
|
||||||
* Miscellaneous
|
* Miscellaneous
|
||||||
*/
|
*/
|
||||||
#define LINUX_AT_COUNT 21 /* Count of used aux entry types.
|
#define LINUX_AT_COUNT 22 /* Count of used aux entry types.
|
||||||
* Keep this synchronized with
|
* Keep this synchronized with
|
||||||
* linux_fixup_elf() code.
|
* linux_fixup_elf() code.
|
||||||
*/
|
*/
|
||||||
|
@ -139,61 +139,15 @@ LINUX_VDSO_SYM_INTPTR(kern_tsc_selector);
|
|||||||
LINUX_VDSO_SYM_INTPTR(kern_cpu_selector);
|
LINUX_VDSO_SYM_INTPTR(kern_cpu_selector);
|
||||||
LINUX_VDSO_SYM_CHAR(linux_platform);
|
LINUX_VDSO_SYM_CHAR(linux_platform);
|
||||||
|
|
||||||
static int
|
void
|
||||||
linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
linux32_arch_copyout_auxargs(struct image_params *imgp, Elf_Auxinfo **pos)
|
||||||
{
|
{
|
||||||
Elf32_Auxargs *args;
|
|
||||||
Elf32_Auxinfo *argarray, *pos;
|
|
||||||
int error, issetugid;
|
|
||||||
|
|
||||||
args = (Elf32_Auxargs *)imgp->auxargs;
|
AUXARGS_ENTRY((*pos), LINUX_AT_SYSINFO, __kernel_vsyscall);
|
||||||
argarray = pos = malloc(LINUX_AT_COUNT * sizeof(*pos), M_TEMP,
|
AUXARGS_ENTRY((*pos), LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
||||||
M_WAITOK | M_ZERO);
|
AUXARGS_ENTRY((*pos), LINUX_AT_HWCAP, cpu_feature);
|
||||||
|
AUXARGS_ENTRY((*pos), LINUX_AT_HWCAP2, 0);
|
||||||
issetugid = imgp->proc->p_flag & P_SUGID ? 1 : 0;
|
AUXARGS_ENTRY((*pos), LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO, __kernel_vsyscall);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Do not export AT_CLKTCK when emulating Linux kernel prior to 2.4.0,
|
|
||||||
* as it has appeared in the 2.4.0-rc7 first time.
|
|
||||||
* Being exported, AT_CLKTCK is returned by sysconf(_SC_CLK_TCK),
|
|
||||||
* glibc falls back to the hard-coded CLK_TCK value when aux entry
|
|
||||||
* is not present.
|
|
||||||
* Also see linux_times() implementation.
|
|
||||||
*/
|
|
||||||
if (linux_kernver(curthread) >= LINUX_KERNVER_2004000)
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
|
||||||
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
|
||||||
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
|
||||||
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
|
||||||
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
|
||||||
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
|
||||||
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_SECURE, issetugid);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_RANDOM, PTROUT(imgp->canary));
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP2, 0);
|
|
||||||
if (imgp->execpathp != 0)
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_EXECFN, PTROUT(imgp->execpathp));
|
|
||||||
if (args->execfd != -1)
|
|
||||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
|
||||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
|
||||||
|
|
||||||
free(imgp->auxargs, M_TEMP);
|
|
||||||
imgp->auxargs = NULL;
|
|
||||||
KASSERT(pos - argarray <= LINUX_AT_COUNT, ("Too many auxargs"));
|
|
||||||
|
|
||||||
error = copyout(argarray, (void *)base,
|
|
||||||
sizeof(*argarray) * LINUX_AT_COUNT);
|
|
||||||
free(argarray, M_TEMP);
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -848,7 +802,7 @@ struct sysentvec elf_linux_sysvec = {
|
|||||||
.sv_psstrings = LINUX32_PS_STRINGS,
|
.sv_psstrings = LINUX32_PS_STRINGS,
|
||||||
.sv_psstringssz = sizeof(struct linux32_ps_strings),
|
.sv_psstringssz = sizeof(struct linux32_ps_strings),
|
||||||
.sv_stackprot = VM_PROT_ALL,
|
.sv_stackprot = VM_PROT_ALL,
|
||||||
.sv_copyout_auxargs = linux_copyout_auxargs,
|
.sv_copyout_auxargs = __linuxN(copyout_auxargs),
|
||||||
.sv_copyout_strings = linux_copyout_strings,
|
.sv_copyout_strings = linux_copyout_strings,
|
||||||
.sv_setregs = linux_exec_setregs,
|
.sv_setregs = linux_exec_setregs,
|
||||||
.sv_fixlimit = linux32_fixlimit,
|
.sv_fixlimit = linux32_fixlimit,
|
||||||
@ -863,6 +817,8 @@ struct sysentvec elf_linux_sysvec = {
|
|||||||
.sv_schedtail = linux_schedtail,
|
.sv_schedtail = linux_schedtail,
|
||||||
.sv_thread_detach = linux_thread_detach,
|
.sv_thread_detach = linux_thread_detach,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
|
.sv_hwcap = NULL,
|
||||||
|
.sv_hwcap2 = NULL,
|
||||||
.sv_onexec = linux_on_exec_vmspace,
|
.sv_onexec = linux_on_exec_vmspace,
|
||||||
.sv_onexit = linux_on_exit,
|
.sv_onexit = linux_on_exit,
|
||||||
.sv_ontdexit = linux_thread_dtor,
|
.sv_ontdexit = linux_thread_dtor,
|
||||||
|
@ -115,7 +115,6 @@ LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
|
|||||||
|
|
||||||
/* DTrace probes */
|
/* DTrace probes */
|
||||||
LIN_SDT_PROBE_DEFINE0(sysvec, linux_exec_setregs, todo);
|
LIN_SDT_PROBE_DEFINE0(sysvec, linux_exec_setregs, todo);
|
||||||
LIN_SDT_PROBE_DEFINE0(sysvec, linux_copyout_auxargs, todo);
|
|
||||||
|
|
||||||
LINUX_VDSO_SYM_CHAR(linux_platform);
|
LINUX_VDSO_SYM_CHAR(linux_platform);
|
||||||
LINUX_VDSO_SYM_INTPTR(kern_timekeep_base);
|
LINUX_VDSO_SYM_INTPTR(kern_timekeep_base);
|
||||||
@ -162,55 +161,14 @@ linux_set_syscall_retval(struct thread *td, int error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
void
|
||||||
linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
linux64_arch_copyout_auxargs(struct image_params *imgp, Elf_Auxinfo **pos)
|
||||||
{
|
{
|
||||||
Elf_Auxargs *args;
|
|
||||||
Elf_Auxinfo *argarray, *pos;
|
|
||||||
struct proc *p;
|
|
||||||
int error, issetugid;
|
|
||||||
|
|
||||||
LIN_SDT_PROBE0(sysvec, linux_copyout_auxargs, todo);
|
AUXARGS_ENTRY((*pos), LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
||||||
p = imgp->proc;
|
AUXARGS_ENTRY((*pos), LINUX_AT_HWCAP, *imgp->sysent->sv_hwcap);
|
||||||
|
AUXARGS_ENTRY((*pos), LINUX_AT_HWCAP2, *imgp->sysent->sv_hwcap2);
|
||||||
args = (Elf64_Auxargs *)imgp->auxargs;
|
AUXARGS_ENTRY((*pos), LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||||
argarray = pos = malloc(LINUX_AT_COUNT * sizeof(*pos), M_TEMP,
|
|
||||||
M_WAITOK | M_ZERO);
|
|
||||||
|
|
||||||
issetugid = p->p_flag & P_SUGID ? 1 : 0;
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_MINSIGSTKSZ, LINUX_MINSIGSTKSZ);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, *imgp->sysent->sv_hwcap);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
|
||||||
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
|
||||||
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
|
||||||
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
|
||||||
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
|
||||||
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
|
||||||
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_SECURE, issetugid);
|
|
||||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP2, *imgp->sysent->sv_hwcap2);
|
|
||||||
if (imgp->execpathp != 0)
|
|
||||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
|
|
||||||
if (args->execfd != -1)
|
|
||||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
|
||||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
|
||||||
|
|
||||||
free(imgp->auxargs, M_TEMP);
|
|
||||||
imgp->auxargs = NULL;
|
|
||||||
KASSERT(pos - argarray <= LINUX_AT_COUNT, ("Too many auxargs"));
|
|
||||||
|
|
||||||
error = copyout(argarray, (void *)base,
|
|
||||||
sizeof(*argarray) * LINUX_AT_COUNT);
|
|
||||||
free(argarray, M_TEMP);
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -425,7 +383,7 @@ struct sysentvec elf_linux_sysvec = {
|
|||||||
.sv_psstrings = LINUX_PS_STRINGS,
|
.sv_psstrings = LINUX_PS_STRINGS,
|
||||||
.sv_psstringssz = sizeof(struct ps_strings),
|
.sv_psstringssz = sizeof(struct ps_strings),
|
||||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE,
|
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE,
|
||||||
.sv_copyout_auxargs = linux_copyout_auxargs,
|
.sv_copyout_auxargs = __linuxN(copyout_auxargs),
|
||||||
.sv_copyout_strings = __linuxN(copyout_strings),
|
.sv_copyout_strings = __linuxN(copyout_strings),
|
||||||
.sv_setregs = linux_exec_setregs,
|
.sv_setregs = linux_exec_setregs,
|
||||||
.sv_fixlimit = NULL,
|
.sv_fixlimit = NULL,
|
||||||
|
@ -488,3 +488,57 @@ linux_trans_osrel(const Elf_Note *note, int32_t *osrel)
|
|||||||
|
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
__linuxN(copyout_auxargs)(struct image_params *imgp, uintptr_t base)
|
||||||
|
{
|
||||||
|
Elf_Auxargs *args;
|
||||||
|
Elf_Auxinfo *aarray, *pos;
|
||||||
|
struct proc *p;
|
||||||
|
int error, issetugid;
|
||||||
|
|
||||||
|
p = imgp->proc;
|
||||||
|
issetugid = p->p_flag & P_SUGID ? 1 : 0;
|
||||||
|
args = imgp->auxargs;
|
||||||
|
aarray = pos = malloc(LINUX_AT_COUNT * sizeof(*pos), M_TEMP,
|
||||||
|
M_WAITOK | M_ZERO);
|
||||||
|
|
||||||
|
__linuxN(arch_copyout_auxargs)(imgp, &pos);
|
||||||
|
/*
|
||||||
|
* Do not export AT_CLKTCK when emulating Linux kernel prior to 2.4.0,
|
||||||
|
* as it has appeared in the 2.4.0-rc7 first time.
|
||||||
|
* Being exported, AT_CLKTCK is returned by sysconf(_SC_CLK_TCK),
|
||||||
|
* glibc falls back to the hard-coded CLK_TCK value when aux entry
|
||||||
|
* is not present.
|
||||||
|
* Also see linux_times() implementation.
|
||||||
|
*/
|
||||||
|
if (linux_kernver(curthread) >= LINUX_KERNVER_2004000)
|
||||||
|
AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
|
||||||
|
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
||||||
|
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
||||||
|
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
||||||
|
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
||||||
|
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
||||||
|
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
||||||
|
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
||||||
|
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
||||||
|
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
||||||
|
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_SECURE, issetugid);
|
||||||
|
AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||||
|
if (imgp->execpathp != 0)
|
||||||
|
AUXARGS_ENTRY(pos, LINUX_AT_EXECFN, PTROUT(imgp->execpathp));
|
||||||
|
if (args->execfd != -1)
|
||||||
|
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
||||||
|
AUXARGS_ENTRY(pos, LINUX_AT_MINSIGSTKSZ, LINUX_MINSIGSTKSZ);
|
||||||
|
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
||||||
|
|
||||||
|
free(imgp->auxargs, M_TEMP);
|
||||||
|
imgp->auxargs = NULL;
|
||||||
|
KASSERT(pos - aarray <= LINUX_AT_COUNT, ("Too many auxargs"));
|
||||||
|
|
||||||
|
error = copyout(aarray, PTRIN(base), sizeof(*aarray) * LINUX_AT_COUNT);
|
||||||
|
free(aarray, M_TEMP);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
@ -42,6 +42,8 @@ struct note_info_list;
|
|||||||
|
|
||||||
void __linuxN(prepare_notes)(struct thread *, struct note_info_list *,
|
void __linuxN(prepare_notes)(struct thread *, struct note_info_list *,
|
||||||
size_t *);
|
size_t *);
|
||||||
|
void __linuxN(arch_copyout_auxargs)(struct image_params *, Elf_Auxinfo **);
|
||||||
|
int __linuxN(copyout_auxargs)(struct image_params *, uintptr_t);
|
||||||
int __linuxN(copyout_strings)(struct image_params *, uintptr_t *);
|
int __linuxN(copyout_strings)(struct image_params *, uintptr_t *);
|
||||||
bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
|
bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ typedef struct {
|
|||||||
/*
|
/*
|
||||||
* Miscellaneous
|
* Miscellaneous
|
||||||
*/
|
*/
|
||||||
#define LINUX_AT_COUNT 20 /* Count of used aux entry types.
|
#define LINUX_AT_COUNT 21 /* Count of used aux entry types.
|
||||||
* Keep this synchronized with
|
* Keep this synchronized with
|
||||||
* linux_fixup_elf() code.
|
* linux_fixup_elf() code.
|
||||||
*/
|
*/
|
||||||
|
@ -138,60 +138,14 @@ linux_fixup(uintptr_t *stack_base, struct image_params *imgp)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
void
|
||||||
linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
linux32_arch_copyout_auxargs(struct image_params *imgp, Elf_Auxinfo **pos)
|
||||||
{
|
{
|
||||||
Elf32_Auxargs *args;
|
|
||||||
Elf32_Auxinfo *argarray, *pos;
|
|
||||||
int error, issetugid;
|
|
||||||
|
|
||||||
issetugid = imgp->proc->p_flag & P_SUGID ? 1 : 0;
|
AUXARGS_ENTRY((*pos), LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
||||||
args = (Elf32_Auxargs *)imgp->auxargs;
|
AUXARGS_ENTRY((*pos), LINUX_AT_SYSINFO, __kernel_vsyscall);
|
||||||
argarray = pos = malloc(LINUX_AT_COUNT * sizeof(*pos), M_TEMP,
|
AUXARGS_ENTRY((*pos), LINUX_AT_HWCAP, cpu_feature);
|
||||||
M_WAITOK | M_ZERO);
|
AUXARGS_ENTRY((*pos), LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||||
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR, linux_vdso_base);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO, __kernel_vsyscall);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Do not export AT_CLKTCK when emulating Linux kernel prior to 2.4.0,
|
|
||||||
* as it has appeared in the 2.4.0-rc7 first time.
|
|
||||||
* Being exported, AT_CLKTCK is returned by sysconf(_SC_CLK_TCK),
|
|
||||||
* glibc falls back to the hard-coded CLK_TCK value when aux entry
|
|
||||||
* is not present.
|
|
||||||
* Also see linux_times() implementation.
|
|
||||||
*/
|
|
||||||
if (linux_kernver(curthread) >= LINUX_KERNVER_2004000)
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
|
||||||
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
|
||||||
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
|
||||||
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
|
||||||
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
|
||||||
AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
|
|
||||||
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
|
||||||
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
|
||||||
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(linux_platform));
|
|
||||||
AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
|
|
||||||
if (imgp->execpathp != 0)
|
|
||||||
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);
|
|
||||||
|
|
||||||
free(imgp->auxargs, M_TEMP);
|
|
||||||
imgp->auxargs = NULL;
|
|
||||||
KASSERT(pos - argarray <= LINUX_AT_COUNT, ("Too many auxargs"));
|
|
||||||
|
|
||||||
error = copyout(argarray, (void *)base,
|
|
||||||
sizeof(*argarray) * LINUX_AT_COUNT);
|
|
||||||
free(argarray, M_TEMP);
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -650,6 +604,8 @@ struct sysentvec linux_sysvec = {
|
|||||||
.sv_schedtail = linux_schedtail,
|
.sv_schedtail = linux_schedtail,
|
||||||
.sv_thread_detach = linux_thread_detach,
|
.sv_thread_detach = linux_thread_detach,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
|
.sv_hwcap = NULL,
|
||||||
|
.sv_hwcap2 = NULL,
|
||||||
.sv_onexec = linux_on_exec_vmspace,
|
.sv_onexec = linux_on_exec_vmspace,
|
||||||
.sv_onexit = linux_on_exit,
|
.sv_onexit = linux_on_exit,
|
||||||
.sv_ontdexit = linux_thread_dtor,
|
.sv_ontdexit = linux_thread_dtor,
|
||||||
@ -678,7 +634,7 @@ struct sysentvec elf_linux_sysvec = {
|
|||||||
.sv_psstrings = LINUX_PS_STRINGS,
|
.sv_psstrings = LINUX_PS_STRINGS,
|
||||||
.sv_psstringssz = sizeof(struct ps_strings),
|
.sv_psstringssz = sizeof(struct ps_strings),
|
||||||
.sv_stackprot = VM_PROT_ALL,
|
.sv_stackprot = VM_PROT_ALL,
|
||||||
.sv_copyout_auxargs = linux_copyout_auxargs,
|
.sv_copyout_auxargs = __linuxN(copyout_auxargs),
|
||||||
.sv_copyout_strings = __linuxN(copyout_strings),
|
.sv_copyout_strings = __linuxN(copyout_strings),
|
||||||
.sv_setregs = linux_exec_setregs,
|
.sv_setregs = linux_exec_setregs,
|
||||||
.sv_fixlimit = NULL,
|
.sv_fixlimit = NULL,
|
||||||
@ -693,6 +649,8 @@ struct sysentvec elf_linux_sysvec = {
|
|||||||
.sv_schedtail = linux_schedtail,
|
.sv_schedtail = linux_schedtail,
|
||||||
.sv_thread_detach = linux_thread_detach,
|
.sv_thread_detach = linux_thread_detach,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
|
.sv_hwcap = NULL,
|
||||||
|
.sv_hwcap2 = NULL,
|
||||||
.sv_onexec = linux_on_exec_vmspace,
|
.sv_onexec = linux_on_exec_vmspace,
|
||||||
.sv_onexit = linux_on_exit,
|
.sv_onexit = linux_on_exit,
|
||||||
.sv_ontdexit = linux_thread_dtor,
|
.sv_ontdexit = linux_thread_dtor,
|
||||||
|
Loading…
Reference in New Issue
Block a user