Added fields for VM_MIN_ADDRESS, PS_STRINGS and stack protections to

sysentvec.  Initialized all fields of all sysentvecs, which will allow
them to be used instead of constants in more places.  Provided stack
fixup routines for emulations that previously used the default.
This commit is contained in:
jake 2002-09-01 21:41:24 +00:00
parent ae4b45674c
commit ce650f8c33
21 changed files with 302 additions and 87 deletions

View File

@ -28,6 +28,8 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/namei.h>
@ -38,6 +40,10 @@
#include <sys/signalvar.h>
#include <sys/vnode.h>
#include <sys/linker.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <machine/elf.h>
#include <machine/md_var.h>
@ -46,11 +52,11 @@ struct sysentvec elf64_freebsd_sysvec = {
sysent,
0,
0,
NULL,
0,
0,
0,
0,
elf64_freebsd_fixup,
NULL,
NULL,
__elfN(freebsd_fixup),
sendsig,
sigcode,
&szsigcode,
@ -58,7 +64,15 @@ struct sysentvec elf64_freebsd_sysvec = {
"FreeBSD ELF64",
__elfN(coredump),
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static Elf64_Brandinfo freebsd_brand_info = {

View File

@ -179,19 +179,27 @@ struct sysentvec elf_linux_sysvec = {
linux_sysent,
0,
0,
NULL,
0,
0,
0,
0,
NULL,
NULL,
elf_linux_fixup,
osendsig,
linux_sigcode,
&linux_szsigcode,
0,
NULL,
"Linux ELF",
elf64_coredump,
exec_linux_imgact_try,
LINUX_MINSIGSTKSZ
LINUX_MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static Elf64_Brandinfo linux_brand = {

View File

@ -64,21 +64,29 @@ static int osf1_freebsd_fixup(long **stack_base, struct image_params *imgp);
struct sysentvec osf1_sysvec = {
OSF1_SYS_MAXSYSCALL,
osf1_sysent,
0x0,
0,
0,
NULL,
0,
0,
0, /* trap-to-signal translation function */
NULL,
NULL, /* trap-to-signal translation function */
osf1_freebsd_fixup, /* fixup */
osf1_sendsig,
sigcode, /* use generic trampoline */
&osf1_szsigcode, /* use generic trampoline size */
0, /* prepsyscall */
NULL, /* prepsyscall */
"OSF/1 ECOFF",
NULL, /* we don't have an ECOFF coredump function */
NULL,
OSF1_MINSIGSTKSZ
OSF1_MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
/*

View File

@ -28,12 +28,19 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/linker.h>
#include <sys/sysent.h>
#include <sys/imgact_elf.h>
#include <sys/syscall.h>
#include <sys/signalvar.h>
#include <sys/vnode.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_param.h>
#include <machine/elf.h>
#include <machine/md_var.h>
@ -42,19 +49,27 @@ struct sysentvec elf32_freebsd_sysvec = {
sysent,
0,
0,
NULL,
0,
0,
0,
0,
elf32_freebsd_fixup,
NULL,
NULL,
__elfN(freebsd_fixup),
sendsig,
sigcode,
&szsigcode,
0,
NULL,
"FreeBSD ELF32",
__elfN(coredump),
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static Elf32_Brandinfo freebsd_brand_info = {

View File

@ -93,22 +93,25 @@ struct sysentvec ia32_freebsd_sysvec = {
ia32_sysent,
0,
0,
NULL,
0,
0,
0,
0,
NULL,
NULL,
elf32_freebsd_fixup,
sendsig,
ia32_sigcode,
&ia32_szsigcode,
0,
NULL,
"FreeBSD ELF",
elf32_coredump,
NULL,
MINSIGSTKSZ,
4096,
0,
IA32_USRSTACK,
IA32_USRSTACK,
IA32_PS_STRINGS,
VM_PROT_ALL,
ia32_copyout_strings,
ia32_setregs
};

View File

@ -93,22 +93,25 @@ struct sysentvec ia32_freebsd_sysvec = {
ia32_sysent,
0,
0,
NULL,
0,
0,
0,
0,
NULL,
NULL,
elf32_freebsd_fixup,
sendsig,
ia32_sigcode,
&ia32_szsigcode,
0,
NULL,
"FreeBSD ELF",
elf32_coredump,
NULL,
MINSIGSTKSZ,
4096,
0,
IA32_USRSTACK,
IA32_USRSTACK,
IA32_PS_STRINGS,
VM_PROT_ALL,
ia32_copyout_strings,
ia32_setregs
};

View File

@ -95,10 +95,10 @@ static struct sysentvec pecoff_sysvec = {
sysent,
0,
0,
NULL,
0,
0,
0,
0,
NULL,
NULL,
pecoff_fixup,
sendsig,
sigcode,
@ -107,7 +107,15 @@ static struct sysentvec pecoff_sysvec = {
"FreeBSD PECoff",
pecoff_coredump,
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};

View File

@ -172,7 +172,7 @@ struct sysentvec svr4_sysvec = {
bsd_to_svr4_sig,
ELAST, /* ELAST */
bsd_to_svr4_errno,
0,
NULL,
svr4_fixup,
svr4_sendsig,
svr4_sigcode,
@ -181,7 +181,15 @@ struct sysentvec svr4_sysvec = {
"SVR4",
elf32_coredump,
NULL,
SVR4_MINSIGSTKSZ
SVR4_MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
Elf32_Brandinfo svr4_brand = {

View File

@ -28,12 +28,19 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/linker.h>
#include <sys/sysent.h>
#include <sys/imgact_elf.h>
#include <sys/syscall.h>
#include <sys/signalvar.h>
#include <sys/vnode.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_param.h>
#include <machine/elf.h>
#include <machine/md_var.h>
@ -42,19 +49,27 @@ struct sysentvec elf32_freebsd_sysvec = {
sysent,
0,
0,
NULL,
0,
0,
0,
0,
elf32_freebsd_fixup,
NULL,
NULL,
__elfN(freebsd_fixup),
sendsig,
sigcode,
&szsigcode,
0,
NULL,
"FreeBSD ELF32",
__elfN(coredump),
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static Elf32_Brandinfo freebsd_brand_info = {

View File

@ -32,6 +32,9 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/sysent.h>
@ -39,6 +42,10 @@
#include <sys/proc.h>
#include <sys/sx.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_param.h>
#include <i386/ibcs2/ibcs2_syscall.h>
#include <i386/ibcs2/ibcs2_signal.h>
@ -48,6 +55,7 @@ extern int bsd_to_ibcs2_errno[];
extern struct sysent ibcs2_sysent[IBCS2_SYS_MAXSYSCALL];
extern int szsigcode;
extern char sigcode[];
static int ibcs2_fixup(register_t **, struct image_params *);
struct sysentvec ibcs2_svr3_sysvec = {
sizeof (ibcs2_sysent) / sizeof (ibcs2_sysent[0]),
@ -57,18 +65,33 @@ struct sysentvec ibcs2_svr3_sysvec = {
bsd_to_ibcs2_sig,
ELAST + 1,
bsd_to_ibcs2_errno,
0, /* trap-to-signal translation function */
0, /* fixup */
NULL, /* trap-to-signal translation function */
ibcs2_fixup, /* fixup */
sendsig,
sigcode, /* use generic trampoline */
&szsigcode, /* use generic trampoline size */
0, /* prepsyscall */
NULL, /* prepsyscall */
"IBCS2 COFF",
NULL, /* we don't have a COFF coredump function */
NULL,
IBCS2_MINSIGSTKSZ
IBCS2_MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static int
ibcs2_fixup(register_t **stack_base, struct image_params *imgp)
{
return (suword(--(*stack_base), imgp->argc));
}
/*
* Create an "ibcs2" module that does nothing but allow checking for
* the presence of the subsystem.

View File

@ -774,7 +774,15 @@ struct sysentvec linux_sysvec = {
"Linux a.out",
aout_coredump,
exec_linux_imgact_try,
LINUX_MINSIGSTKSZ
LINUX_MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
struct sysentvec elf_linux_sysvec = {
@ -794,7 +802,15 @@ struct sysentvec elf_linux_sysvec = {
"Linux ELF",
elf32_coredump,
exec_linux_imgact_try,
LINUX_MINSIGSTKSZ
LINUX_MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static Elf32_Brandinfo linux_brand = {

View File

@ -93,22 +93,25 @@ struct sysentvec ia32_freebsd_sysvec = {
ia32_sysent,
0,
0,
NULL,
0,
0,
0,
0,
NULL,
NULL,
elf32_freebsd_fixup,
sendsig,
ia32_sigcode,
&ia32_szsigcode,
0,
NULL,
"FreeBSD ELF",
elf32_coredump,
NULL,
MINSIGSTKSZ,
4096,
0,
IA32_USRSTACK,
IA32_USRSTACK,
IA32_PS_STRINGS,
VM_PROT_ALL,
ia32_copyout_strings,
ia32_setregs
};

View File

@ -93,22 +93,25 @@ struct sysentvec ia32_freebsd_sysvec = {
ia32_sysent,
0,
0,
NULL,
0,
0,
0,
0,
NULL,
NULL,
elf32_freebsd_fixup,
sendsig,
ia32_sigcode,
&ia32_szsigcode,
0,
NULL,
"FreeBSD ELF",
elf32_coredump,
NULL,
MINSIGSTKSZ,
4096,
0,
IA32_USRSTACK,
IA32_USRSTACK,
IA32_PS_STRINGS,
VM_PROT_ALL,
ia32_copyout_strings,
ia32_setregs
};

View File

@ -28,6 +28,8 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/namei.h>
@ -38,6 +40,10 @@
#include <sys/imgact_elf.h>
#include <sys/syscall.h>
#include <sys/signalvar.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <machine/elf.h>
#include <machine/md_var.h>
@ -46,19 +52,27 @@ struct sysentvec elf64_freebsd_sysvec = {
sysent,
0,
0,
NULL,
0,
0,
0,
0,
elf64_freebsd_fixup,
NULL,
NULL,
__elfN(freebsd_fixup),
sendsig,
sigcode,
&szsigcode,
0,
NULL,
"FreeBSD ELF64",
__elfN(coredump),
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static Elf64_Brandinfo freebsd_brand_info = {

View File

@ -57,27 +57,45 @@
#include <vm/vm_object.h>
static int exec_aout_imgact(struct image_params *imgp);
static int aout_fixup(register_t **stack_base, struct image_params *imgp);
struct sysentvec aout_sysvec = {
SYS_MAXSYSCALL,
sysent,
0,
0,
NULL,
0,
0,
0,
0,
0,
NULL,
NULL,
aout_fixup,
sendsig,
sigcode,
&szsigcode,
0,
NULL,
"FreeBSD a.out",
aout_coredump,
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static int
aout_fixup(stack_base, imgp)
register_t **stack_base;
struct image_params *imgp;
{
return (suword(--(*stack_base), imgp->argc));
}
static int
exec_aout_imgact(imgp)
struct image_params *imgp;

View File

@ -47,6 +47,7 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/exec.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/ktr.h>
@ -255,8 +256,33 @@ set_boot_verbose(void *data __unused)
}
SYSINIT(boot_verbose, SI_SUB_TUNABLES, SI_ORDER_ANY, set_boot_verbose, NULL)
static struct sysentvec null_sysvec;
struct sysentvec null_sysvec = {
0,
NULL,
0,
0,
NULL,
0,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"null",
NULL,
NULL,
0,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
NULL,
NULL
};
/*
***************************************************************************

View File

@ -85,8 +85,6 @@ struct execlist {
TAILQ_HEAD(exec_list_head, execlist);
static struct exec_list_head exec_list = TAILQ_HEAD_INITIALIZER(exec_list);
static register_t *exec_copyout_strings(struct image_params *);
/* XXX This should be vm_size_t. */
static u_long ps_strings = PS_STRINGS;
SYSCTL_ULONG(_kern, KERN_PS_STRINGS, ps_strings, CTLFLAG_RD, &ps_strings,

View File

@ -28,6 +28,8 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/namei.h>
@ -38,6 +40,10 @@
#include <sys/signalvar.h>
#include <sys/vnode.h>
#include <sys/linker.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <machine/elf.h>
#include <machine/md_var.h>
@ -46,19 +52,27 @@ struct sysentvec elf32_freebsd_sysvec = {
sysent,
0,
0,
NULL,
0,
0,
0,
0,
elf32_freebsd_fixup,
NULL,
NULL,
__elfN(freebsd_fixup),
sendsig,
sigcode,
&szsigcode,
0,
NULL,
"FreeBSD ELF32",
__elfN(coredump),
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_ALL,
exec_copyout_strings,
exec_setregs
};
static Elf32_Brandinfo freebsd_brand_info = {

View File

@ -42,14 +42,19 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/imgact.h>
#include <sys/linker.h>
#include <sys/sysent.h>
#include <sys/imgact_elf.h>
#include <sys/syscall.h>
#include <sys/signalvar.h>
#include <sys/vnode.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <machine/elf.h>
#include <machine/md_var.h>
#include "linker_if.h"
@ -58,19 +63,27 @@ struct sysentvec elf64_freebsd_sysvec = {
sysent,
0,
0,
NULL,
0,
0,
0,
0,
elf64_freebsd_fixup,
NULL,
NULL,
__elfN(freebsd_fixup),
sendsig,
NULL,
NULL,
0,
NULL,
"FreeBSD ELF64",
__elfN(coredump),
NULL,
MINSIGSTKSZ
MINSIGSTKSZ,
PAGE_SIZE,
VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS,
USRSTACK,
PS_STRINGS,
VM_PROT_READ | VM_PROT_WRITE,
exec_copyout_strings,
exec_setregs
};
static Elf64_Brandinfo freebsd_brand_info = {

View File

@ -67,6 +67,7 @@ struct image_params {
#ifdef _KERNEL
int exec_check_permissions(struct image_params *);
register_t *exec_copyout_strings(struct image_params *);
int exec_extract_strings(struct image_params *);
int exec_new_vmspace(struct image_params *, vm_offset_t, vm_offset_t,
vm_offset_t);

View File

@ -79,9 +79,12 @@ struct sysentvec {
/* function to dump core, or NULL */
int (*sv_imgact_try)(struct image_params *);
int sv_minsigstksz; /* minimum signal stack size */
int sv_pagesize; /* pagesize override */
vm_offset_t sv_maxuser; /* VM_MAXUSER_ADDRESS override */
vm_offset_t sv_usrstack; /* USRSTACK override */
int sv_pagesize; /* pagesize */
vm_offset_t sv_minuser; /* VM_MIN_ADDRESS */
vm_offset_t sv_maxuser; /* VM_MAXUSER_ADDRESS */
vm_offset_t sv_usrstack; /* USRSTACK */
vm_offset_t sv_psstrings; /* PS_STRINGS */
int sv_stackprot; /* vm protection for stack */
register_t *(*sv_copyout_strings)(struct image_params *);
void (*sv_setregs)(struct thread *, u_long, u_long, u_long);
};
@ -89,6 +92,7 @@ struct sysentvec {
#ifdef _KERNEL
extern struct sysentvec aout_sysvec;
extern struct sysentvec elf_freebsd_sysvec;
extern struct sysentvec null_sysvec;
extern struct sysent sysent[];
#define NO_SYSCALL (-1)