summaryrefslogtreecommitdiffstats
path: root/sys/compat/svr4/svr4_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/svr4/svr4_misc.c')
-rw-r--r--sys/compat/svr4/svr4_misc.c63
1 files changed, 31 insertions, 32 deletions
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;
OpenPOWER on IntegriCloud