diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/imgact_aout.c | 2 | ||||
-rw-r--r-- | sys/kern/imgact_elf.c | 2 | ||||
-rw-r--r-- | sys/kern/imgact_gzip.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_environment.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 10 | ||||
-rw-r--r-- | sys/kern/kern_resource.c | 17 | ||||
-rw-r--r-- | sys/kern/subr_param.c | 21 | ||||
-rw-r--r-- | sys/kern/sysv_shm.c | 3 |
8 files changed, 45 insertions, 20 deletions
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index 5a53581..bd6ff7b 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -163,7 +163,7 @@ exec_aout_imgact(imgp) */ mtx_assert(&Giant, MA_OWNED); if (/* text can't exceed maximum text size */ - a_out->a_text > MAXTSIZ || + a_out->a_text > maxtsiz || /* data + bss can't exceed rlimit */ a_out->a_data + bss_size > diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index d7a27ba..8d6a2bd 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -30,8 +30,6 @@ * $FreeBSD$ */ -#include "opt_rlimit.h" - #include <sys/param.h> #include <sys/exec.h> #include <sys/fcntl.h> diff --git a/sys/kern/imgact_gzip.c b/sys/kern/imgact_gzip.c index 00f9040..3516daa 100644 --- a/sys/kern/imgact_gzip.c +++ b/sys/kern/imgact_gzip.c @@ -209,7 +209,7 @@ do_aout_hdr(struct imgact_gzip * gz) */ mtx_assert(&Giant, MA_OWNED); if ( /* text can't exceed maximum text size */ - gz->a_out.a_text > MAXTSIZ || + gz->a_out.a_text > maxtsiz || /* data + bss can't exceed rlimit */ gz->a_out.a_data + gz->bss_size > diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index a3342b4..9789706 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -163,6 +163,14 @@ tunable_int_init(void *data) } void +tunable_quad_init(void *data) +{ + struct tunable_quad *d = (struct tunable_quad *)data; + + TUNABLE_QUAD_FETCH(d->path, d->var); +} + +void tunable_str_init(void *data) { struct tunable_str *d = (struct tunable_str *)data; diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 8cfeb74..32df1c2 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -551,7 +551,7 @@ exec_new_vmspace(imgp) { int error; struct vmspace *vmspace = imgp->proc->p_vmspace; - caddr_t stack_addr = (caddr_t) (USRSTACK - MAXSSIZ); + caddr_t stack_addr = (caddr_t) (USRSTACK - maxssiz); vm_map_t map = &vmspace->vm_map; GIANT_REQUIRED; @@ -576,7 +576,7 @@ exec_new_vmspace(imgp) /* Allocate a new stack */ error = vm_map_stack (&vmspace->vm_map, (vm_offset_t)stack_addr, - (vm_size_t)MAXSSIZ, VM_PROT_ALL, VM_PROT_ALL, 0); + (vm_size_t)maxssiz, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) return (error); @@ -588,7 +588,7 @@ exec_new_vmspace(imgp) * store to grow upwards. This will do for now. */ vm_offset_t bsaddr; - bsaddr = USRSTACK - 2*MAXSSIZ; + bsaddr = USRSTACK - 2*maxssiz; error = vm_map_find(&vmspace->vm_map, 0, 0, &bsaddr, 4*PAGE_SIZE, 0, VM_PROT_ALL, VM_PROT_ALL, 0); @@ -600,8 +600,8 @@ exec_new_vmspace(imgp) * VM_STACK case, but they are still used to monitor the size of the * process stack so we can check the stack rlimit. */ - vmspace->vm_ssize = SGROWSIZ >> PAGE_SHIFT; - vmspace->vm_maxsaddr = (char *)USRSTACK - MAXSSIZ; + vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT; + vmspace->vm_maxsaddr = (char *)USRSTACK - maxssiz; return(0); } diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 093e4c2..b5eeb5e 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -40,7 +40,6 @@ */ #include "opt_compat.h" -#include "opt_rlimit.h" #include <sys/param.h> #include <sys/systm.h> @@ -518,17 +517,17 @@ dosetrlimit(td, which, limp) (rlim_t)1000000 * limp->rlim_cur; break; case RLIMIT_DATA: - if (limp->rlim_cur > MAXDSIZ) - limp->rlim_cur = MAXDSIZ; - if (limp->rlim_max > MAXDSIZ) - limp->rlim_max = MAXDSIZ; + if (limp->rlim_cur > maxdsiz) + limp->rlim_cur = maxdsiz; + if (limp->rlim_max > maxdsiz) + limp->rlim_max = maxdsiz; break; case RLIMIT_STACK: - if (limp->rlim_cur > MAXSSIZ) - limp->rlim_cur = MAXSSIZ; - if (limp->rlim_max > MAXSSIZ) - limp->rlim_max = MAXSSIZ; + if (limp->rlim_cur > maxssiz) + limp->rlim_cur = maxssiz; + if (limp->rlim_max > maxssiz) + limp->rlim_max = maxssiz; /* * Stack is allocated to the max at exec time with only * "rlim_cur" bytes accessible. If stack limit is going diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 96398dc..ced6d95 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -46,6 +46,8 @@ #include <sys/systm.h> #include <sys/kernel.h> +#include <machine/vmparam.h> + /* * System parameter formulae. */ @@ -74,6 +76,12 @@ int nbuf; int nswbuf; int maxswzone; /* max swmeta KVA storage */ int maxbcache; /* max buffer cache KVA storage */ +u_quad_t maxtsiz; /* max text size */ +u_quad_t dfldsiz; /* initial data size limit */ +u_quad_t maxdsiz; /* max data size */ +u_quad_t dflssiz; /* initial stack size limit */ +u_quad_t maxssiz; /* max stack size */ +u_quad_t sgrowsiz; /* amount to grow stack */ /* * These have to be allocated somewhere; allocating @@ -126,4 +134,17 @@ init_param(void) TUNABLE_INT_FETCH("kern.maxbcache", &maxbcache); ncallout = 16 + maxproc + maxfiles; TUNABLE_INT_FETCH("kern.ncallout", &ncallout); + + maxtsiz = MAXTSIZ; + TUNABLE_QUAD_FETCH("kern.maxtsiz", &maxtsiz); + dfldsiz = DFLDSIZ; + TUNABLE_QUAD_FETCH("kern.dfldsiz", &dfldsiz); + maxdsiz = MAXDSIZ; + TUNABLE_QUAD_FETCH("kern.maxdsiz", &maxdsiz); + dflssiz = DFLSSIZ; + TUNABLE_QUAD_FETCH("kern.dflssiz", &dflssiz); + maxssiz = MAXSSIZ; + TUNABLE_QUAD_FETCH("kern.maxssiz", &maxssiz); + sgrowsiz = SGROWSIZ; + TUNABLE_QUAD_FETCH("kern.sgrowsiz", &sgrowsiz); } diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index 650bee7..74743e5 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -32,7 +32,6 @@ */ #include "opt_compat.h" -#include "opt_rlimit.h" #include "opt_sysvipc.h" #include <sys/param.h> @@ -355,7 +354,7 @@ shmat(td, uap) * put it. */ attach_va = round_page((vm_offset_t)p->p_vmspace->vm_taddr - + MAXTSIZ + MAXDSIZ); + + maxtsiz + maxdsiz); } shm_handle = shmseg->shm_internal; |