summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/alpha/linux/linux_sysvec.c19
-rw-r--r--sys/compat/svr4/svr4_sysvec.c16
-rw-r--r--sys/i386/linux/linux_sysvec.c10
3 files changed, 23 insertions, 22 deletions
diff --git a/sys/alpha/linux/linux_sysvec.c b/sys/alpha/linux/linux_sysvec.c
index 9e9e1f9..40deced 100644
--- a/sys/alpha/linux/linux_sysvec.c
+++ b/sys/alpha/linux/linux_sysvec.c
@@ -81,25 +81,26 @@ SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
void osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code);
-static int elf_linux_fixup(long **stack_base,
+static int elf_linux_fixup(register_t **stack_base,
struct image_params *iparams);
static int exec_linux_imgact_try(struct image_params *iparams);
static int
-elf_linux_fixup(long **stack_base, struct image_params *imgp)
+elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
{
- long *pos;
Elf64_Auxargs *args;
+ register_t *pos;
+ KASSERT(curthread->td_proc == imgp->proc &&
+ (curthread->td_proc->p_flag & P_THREADED) == 0,
+ ("unsafe elf_linux_fixup(), should be curproc"));
args = (Elf64_Auxargs *)imgp->auxargs;
pos = *stack_base + (imgp->argc + imgp->envc + 2);
- if (args->trace) {
+ if (args->trace)
AUXARGS_ENTRY(pos, AT_DEBUG, 1);
- }
- if (args->execfd != -1) {
+ if (args->execfd != -1)
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
- }
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
@@ -107,19 +108,17 @@ elf_linux_fixup(long **stack_base, struct image_params *imgp)
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
AUXARGS_ENTRY(pos, AT_BASE, args->base);
- PROC_LOCK(imgp->proc);
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);
- PROC_UNLOCK(imgp->proc);
AUXARGS_ENTRY(pos, AT_NULL, 0);
free(imgp->auxargs, M_TEMP);
imgp->auxargs = NULL;
(*stack_base)--;
- **stack_base = (long)imgp->argc;
+ **stack_base = (register_t)imgp->argc;
return 0;
}
diff --git a/sys/compat/svr4/svr4_sysvec.c b/sys/compat/svr4/svr4_sysvec.c
index 1d4ad6e..ec8ce8b 100644
--- a/sys/compat/svr4/svr4_sysvec.c
+++ b/sys/compat/svr4/svr4_sysvec.c
@@ -206,17 +206,19 @@ const char svr4_emul_path[] = "/compat/svr4";
static int
svr4_fixup(register_t **stack_base, struct image_params *imgp)
{
- Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs;
+ Elf32_Auxargs *args;
register_t *pos;
+ KASSERT(curthread->td_proc == imgp->proc &&
+ (curthread->td_proc->p_flag & P_THREADED) == 0,
+ ("unsafe svr4_fixup(), should be curproc"));
+ args = (Elf32_Auxargs *)imgp->auxargs;
pos = *stack_base + (imgp->argc + imgp->envc + 2);
- if (args->trace) {
+ if (args->trace)
AUXARGS_ENTRY(pos, AT_DEBUG, 1);
- }
- if (args->execfd != -1) {
+ if (args->execfd != -1)
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
- }
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
@@ -224,19 +226,17 @@ svr4_fixup(register_t **stack_base, struct image_params *imgp)
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
AUXARGS_ENTRY(pos, AT_BASE, args->base);
- PROC_LOCK(imgp->proc);
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);
- PROC_UNLOCK(imgp->proc);
AUXARGS_ENTRY(pos, AT_NULL, 0);
free(imgp->auxargs, M_TEMP);
imgp->auxargs = NULL;
(*stack_base)--;
- **stack_base = (int)imgp->argc;
+ **stack_base = (register_t)imgp->argc;
return 0;
}
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index 407348d..c324f82 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -228,9 +228,13 @@ linux_fixup(register_t **stack_base, struct image_params *imgp)
static int
elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
{
- Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs;
+ Elf32_Auxargs *args;
register_t *pos;
+ KASSERT(curthread->td_proc == imgp->proc &&
+ (curthread->td_proc->p_flag & P_THREADED) == 0,
+ ("unsafe elf_linux_fixup(), should be curproc"));
+ args = (Elf32_Auxargs *)imgp->auxargs;
pos = *stack_base + (imgp->argc + imgp->envc + 2);
if (args->trace)
@@ -244,19 +248,17 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
AUXARGS_ENTRY(pos, AT_BASE, args->base);
- PROC_LOCK(imgp->proc);
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);
- PROC_UNLOCK(imgp->proc);
AUXARGS_ENTRY(pos, AT_NULL, 0);
free(imgp->auxargs, M_TEMP);
imgp->auxargs = NULL;
(*stack_base)--;
- **stack_base = (long)imgp->argc;
+ **stack_base = (register_t)imgp->argc;
return 0;
}
OpenPOWER on IntegriCloud