summaryrefslogtreecommitdiffstats
path: root/sys/compat/svr4
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/svr4')
-rw-r--r--sys/compat/svr4/imgact_svr4.c8
-rw-r--r--sys/compat/svr4/svr4_filio.c11
-rw-r--r--sys/compat/svr4/svr4_misc.c63
-rw-r--r--sys/compat/svr4/svr4_resource.c52
4 files changed, 69 insertions, 65 deletions
diff --git a/sys/compat/svr4/imgact_svr4.c b/sys/compat/svr4/imgact_svr4.c
index 5d8d550..4dc5b8f 100644
--- a/sys/compat/svr4/imgact_svr4.c
+++ b/sys/compat/svr4/imgact_svr4.c
@@ -104,14 +104,16 @@ exec_svr4_imgact(imgp)
/* text + data can't exceed file size */
if (a_out->a_data + a_out->a_text > imgp->attr->va_size)
return (EFAULT);
- /* For p_rlimit below. */
- mtx_assert(&Giant, MA_OWNED);
/*
* text/data/bss must not exceed limits
*/
+ PROC_LOCK(imgp->proc);
if (a_out->a_text > maxtsiz ||
- a_out->a_data + bss_size > imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur)
+ a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA)) {
+ PROC_UNLOCK(imgp->proc);
return (ENOMEM);
+ }
+ PROC_UNLOCK(imgp->proc);
VOP_UNLOCK(imgp->vp, 0, td);
diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c
index 79b9bf4..c15c5b4 100644
--- a/sys/compat/svr4/svr4_filio.c
+++ b/sys/compat/svr4/svr4_filio.c
@@ -66,10 +66,13 @@ svr4_sys_poll(td, uap)
int idx = 0, cerr;
u_long siz;
- mtx_assert(&Giant, MA_OWNED);
- if (uap->nfds > td->td_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur &&
- uap->nfds > FD_SETSIZE)
- return (EINVAL);
+ PROC_LOCK(td->td_proc);
+ if (uap->nfds > lim_cur(td->td_proc, RLIMIT_NOFILE) &&
+ uap->nfds > FD_SETSIZE) {
+ PROC_UNLOCK(td->td_proc);
+ return (EINVAL);
+ }
+ PROC_UNLOCK(td->td_proc);
pa.fds = uap->fds;
pa.nfds = uap->nfds;
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index f29ee8b..c568a5d 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -820,15 +820,15 @@ svr4_sys_break(td, uap)
base = round_page((vm_offset_t) vm->vm_daddr);
ns = (vm_offset_t)uap->nsize;
new = round_page(ns);
- /* For p_rlimit. */
- mtx_assert(&Giant, MA_OWNED);
if (new > base) {
- if ((new - base) > (unsigned) td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur) {
+ PROC_LOCK(p);
+ if ((new - base) > (unsigned)lim_cur(p, RLIMIT_DATA)) {
+ PROC_UNLOCK(p);
return ENOMEM;
- }
- if (new >= VM_MAXUSER_ADDRESS) {
- return (ENOMEM);
- }
+ }
+ PROC_UNLOCK(p);
+ if (new >= VM_MAXUSER_ADDRESS)
+ return (ENOMEM);
} else if (new < base) {
/*
* This is simply an invalid value. If someone wants to
@@ -843,8 +843,12 @@ svr4_sys_break(td, uap)
if (new > old) {
vm_size_t diff;
diff = new - old;
- if (vm->vm_map.size + diff > p->p_rlimit[RLIMIT_VMEM].rlim_cur)
+ PROC_LOCK(p);
+ if (vm->vm_map.size + diff > lim_cur(p, RLIMIT_VMEM)) {
+ PROC_UNLOCK(p);
return(ENOMEM);
+ }
+ PROC_UNLOCK(p);
rv = vm_map_find(&vm->vm_map, NULL, 0, &old, diff, FALSE,
VM_PROT_ALL, VM_PROT_ALL, 0);
if (rv != KERN_SUCCESS) {
@@ -922,42 +926,33 @@ svr4_sys_ulimit(td, uap)
struct svr4_sys_ulimit_args *uap;
{
int *retval = td->td_retval;
+ int error;
switch (uap->cmd) {
case SVR4_GFILLIM:
- /* For p_rlimit below. */
- mtx_assert(&Giant, MA_OWNED);
- *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512;
+ PROC_LOCK(td->td_proc);
+ *retval = lim_cur(td->td_proc, RLIMIT_FSIZE) / 512;
+ PROC_UNLOCK(td->td_proc);
if (*retval == -1)
*retval = 0x7fffffff;
return 0;
case SVR4_SFILLIM:
{
- int error;
- struct __setrlimit_args srl;
struct rlimit krl;
- caddr_t sg = stackgap_init();
- struct rlimit *url = (struct rlimit *)
- stackgap_alloc(&sg, sizeof *url);
krl.rlim_cur = uap->newlimit * 512;
- mtx_assert(&Giant, MA_OWNED);
- krl.rlim_max = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_max;
-
- error = copyout(&krl, url, sizeof(*url));
- if (error)
- return error;
-
- srl.which = RLIMIT_FSIZE;
- srl.rlp = url;
+ PROC_LOCK(td->td_proc);
+ krl.rlim_max = lim_max(td->td_proc, RLIMIT_FSIZE);
+ PROC_UNLOCK(td->td_proc);
- error = setrlimit(td, &srl);
+ error = kern_setrlimit(td, RLIMIT_FSIZE, &krl);
if (error)
return error;
- mtx_assert(&Giant, MA_OWNED);
- *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur;
+ PROC_LOCK(td->td_proc);
+ *retval = lim_cur(td->td_proc, RLIMIT_FSIZE);
+ PROC_UNLOCK(td->td_proc);
if (*retval == -1)
*retval = 0x7fffffff;
return 0;
@@ -968,12 +963,15 @@ svr4_sys_ulimit(td, uap)
struct vmspace *vm = td->td_proc->p_vmspace;
register_t r;
- mtx_assert(&Giant, MA_OWNED);
- r = td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur;
+ PROC_LOCK(td->td_proc);
+ r = lim_cur(td->td_proc, RLIMIT_DATA);
+ PROC_UNLOCK(td->td_proc);
if (r == -1)
r = 0x7fffffff;
+ mtx_lock(&Giant); /* XXX */
r += (long) vm->vm_daddr;
+ mtx_unlock(&Giant);
if (r < 0)
r = 0x7fffffff;
*retval = r;
@@ -981,8 +979,9 @@ svr4_sys_ulimit(td, uap)
}
case SVR4_GDESLIM:
- mtx_assert(&Giant, MA_OWNED);
- *retval = td->td_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur;
+ PROC_LOCK(td->td_proc);
+ *retval = lim_cur(td->td_proc, RLIMIT_NOFILE);
+ PROC_UNLOCK(td->td_proc);
if (*retval == -1)
*retval = 0x7fffffff;
return 0;
diff --git a/sys/compat/svr4/svr4_resource.c b/sys/compat/svr4/svr4_resource.c
index f04d591..6aed48d 100644
--- a/sys/compat/svr4/svr4_resource.c
+++ b/sys/compat/svr4/svr4_resource.c
@@ -136,9 +136,9 @@ svr4_sys_getrlimit(td, uap)
if (rl == -1)
return EINVAL;
- /* For p_rlimit. */
- mtx_assert(&Giant, MA_OWNED);
- blim = td->td_proc->p_rlimit[rl];
+ PROC_LOCK(td->td_proc);
+ lim_rlimit(td->td_proc, rl, &blim);
+ PROC_UNLOCK(td->td_proc);
/*
* Our infinity, is their maxfiles.
@@ -177,20 +177,20 @@ svr4_sys_setrlimit(td, uap)
struct svr4_sys_setrlimit_args *uap;
{
int rl = svr4_to_native_rl(uap->which);
- struct rlimit blim, *limp;
+ struct rlimit blim, curlim;
struct svr4_rlimit slim;
int error;
if (rl == -1)
return EINVAL;
- /* For p_rlimit. */
- mtx_assert(&Giant, MA_OWNED);
- limp = &td->td_proc->p_rlimit[rl];
-
if ((error = copyin(uap->rlp, &slim, sizeof(slim))) != 0)
return error;
+ PROC_LOCK(td->td_proc);
+ lim_rlimit(td->td_proc, rl, &curlim);
+ PROC_UNLOCK(td->td_proc);
+
/*
* if the limit is SVR4_RLIM_INFINITY, then we set it to our
* unlimited.
@@ -205,20 +205,20 @@ svr4_sys_setrlimit(td, uap)
else if (OKLIMIT(slim.rlim_max))
blim.rlim_max = (rlim_t) slim.rlim_max;
else if (slim.rlim_max == SVR4_RLIM_SAVED_MAX)
- blim.rlim_max = limp->rlim_max;
+ blim.rlim_max = curlim.rlim_max;
else if (slim.rlim_max == SVR4_RLIM_SAVED_CUR)
- blim.rlim_max = limp->rlim_cur;
+ blim.rlim_max = curlim.rlim_cur;
if (slim.rlim_cur == SVR4_RLIM_INFINITY)
blim.rlim_cur = RLIM_INFINITY;
else if (OKLIMIT(slim.rlim_cur))
blim.rlim_cur = (rlim_t) slim.rlim_cur;
else if (slim.rlim_cur == SVR4_RLIM_SAVED_MAX)
- blim.rlim_cur = limp->rlim_max;
+ blim.rlim_cur = curlim.rlim_max;
else if (slim.rlim_cur == SVR4_RLIM_SAVED_CUR)
- blim.rlim_cur = limp->rlim_cur;
+ blim.rlim_cur = curlim.rlim_cur;
- return dosetrlimit(td, rl, &blim);
+ return (kern_setrlimit(td, rl, &blim));
}
@@ -234,9 +234,9 @@ svr4_sys_getrlimit64(td, uap)
if (rl == -1)
return EINVAL;
- /* For p_rlimit. */
- mtx_assert(&Giant, MA_OWNED);
- blim = td->td_proc->p_rlimit[rl];
+ PROC_LOCK(td->td_proc);
+ lim_rlimit(td->td_proc, rl, &blim);
+ PROC_UNLOCK(td->td_proc);
/*
* Our infinity, is their maxfiles.
@@ -275,20 +275,20 @@ svr4_sys_setrlimit64(td, uap)
struct svr4_sys_setrlimit64_args *uap;
{
int rl = svr4_to_native_rl(uap->which);
- struct rlimit blim, *limp;
+ struct rlimit blim, curlim;
struct svr4_rlimit64 slim;
int error;
if (rl == -1)
return EINVAL;
- /* For p_rlimit. */
- mtx_assert(&Giant, MA_OWNED);
- limp = &td->td_proc->p_rlimit[rl];
-
if ((error = copyin(uap->rlp, &slim, sizeof(slim))) != 0)
return error;
+ PROC_LOCK(td->td_proc);
+ lim_rlimit(td->td_proc, rl, &curlim);
+ PROC_UNLOCK(td->td_proc);
+
/*
* if the limit is SVR4_RLIM64_INFINITY, then we set it to our
* unlimited.
@@ -303,18 +303,18 @@ svr4_sys_setrlimit64(td, uap)
else if (OKLIMIT64(slim.rlim_max))
blim.rlim_max = (rlim_t) slim.rlim_max;
else if (slim.rlim_max == SVR4_RLIM64_SAVED_MAX)
- blim.rlim_max = limp->rlim_max;
+ blim.rlim_max = curlim.rlim_max;
else if (slim.rlim_max == SVR4_RLIM64_SAVED_CUR)
- blim.rlim_max = limp->rlim_cur;
+ blim.rlim_max = curlim.rlim_cur;
if (slim.rlim_cur == SVR4_RLIM64_INFINITY)
blim.rlim_cur = RLIM_INFINITY;
else if (OKLIMIT64(slim.rlim_cur))
blim.rlim_cur = (rlim_t) slim.rlim_cur;
else if (slim.rlim_cur == SVR4_RLIM64_SAVED_MAX)
- blim.rlim_cur = limp->rlim_max;
+ blim.rlim_cur = curlim.rlim_max;
else if (slim.rlim_cur == SVR4_RLIM64_SAVED_CUR)
- blim.rlim_cur = limp->rlim_cur;
+ blim.rlim_cur = curlim.rlim_cur;
- return dosetrlimit(td, rl, &blim);
+ return (kern_setrlimit(td, rl, &blim));
}
OpenPOWER on IntegriCloud