There is no need to use the stackgap for get/setrlimit.

This commit is contained in:
dsl 2007-05-12 21:07:02 +00:00
parent 058554bbc4
commit 8beba9d093
4 changed files with 66 additions and 122 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_resource_43.c,v 1.19 2007/03/04 06:01:13 christos Exp $ */
/* $NetBSD: kern_resource_43.c,v 1.20 2007/05/12 21:07:02 dsl Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_resource_43.c,v 1.19 2007/03/04 06:01:13 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_resource_43.c,v 1.20 2007/05/12 21:07:02 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -69,8 +69,7 @@ compat_43_sys_getrlimit(struct lwp *l, void *v, register_t *retval)
olim.rlim_max = p->p_rlimit[which].rlim_max;
if (olim.rlim_max == -1)
olim.rlim_max = 0x7fffffff;
return (copyout((void *)&olim, (void *)SCARG(uap, rlp),
sizeof(olim)));
return copyout(&olim, SCARG(uap, rlp), sizeof(olim));
}
/* ARGSUSED */

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_resource.c,v 1.8 2007/03/04 06:01:17 christos Exp $ */
/* $NetBSD: irix_resource.c,v 1.9 2007/05/12 21:07:02 dsl Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_resource.c,v 1.8 2007/03/04 06:01:17 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_resource.c,v 1.9 2007/05/12 21:07:02 dsl Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@ -105,36 +105,27 @@ irix_sys_getrlimit(l, v, retval)
syscallarg(int) resource;
syscallarg(struct irix_rlimit *) rlp;
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_getrlimit_args cup;
struct rlimit rlp;
struct rlimit *rlp;
struct irix_rlimit irlp;
int error;
int which;
SCARG(&cup, which) = irix_to_native_resource(SCARG(uap, resource));
SCARG(&cup, rlp) = stackgap_alloc(p, &sg, sizeof(struct rlimit));
which = irix_to_native_resource(SCARG(uap, resource));
if (which < 0)
return EINVAL;
if ((error = sys_getrlimit(l, &cup, retval)) != 0)
return error;
rlp = &l->l_proc->p_rlimit[which];
if ((error = copyin(SCARG(&cup, rlp), &rlp, sizeof(rlp))) != 0)
return error;
if (rlp.rlim_cur == RLIM_INFINITY)
if (rlp->rlim_cur == RLIM_INFINITY)
irlp.rlim_cur = IRIX_RLIM_INFINITY;
else
irlp.rlim_cur = rlp.rlim_cur;
irlp.rlim_cur = rlp->rlim_cur;
if (rlp.rlim_max == RLIM_INFINITY)
if (rlp->rlim_max == RLIM_INFINITY)
irlp.rlim_max = IRIX_RLIM_INFINITY;
else
irlp.rlim_max = rlp.rlim_cur;
irlp.rlim_max = rlp->rlim_cur;
if ((error = copyout(&irlp, SCARG(uap, rlp), sizeof(irlp))) != 0)
return error;
return 0;
return copyout(&irlp, SCARG(uap, rlp), sizeof(irlp));
}
int
@ -147,36 +138,27 @@ irix_sys_getrlimit64(l, v, retval)
syscallarg(int) resource;
syscallarg(struct irix_rlimit64 *) rlp;
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_getrlimit_args cup;
struct rlimit rlp;
struct rlimit *rlp;
struct irix_rlimit64 irlp;
int error;
int which;
SCARG(&cup, which) = irix_to_native_resource(SCARG(uap, resource));
SCARG(&cup, rlp) = stackgap_alloc(p, &sg, sizeof(struct rlimit));
which = irix_to_native_resource(SCARG(uap, resource));
if (which < 0)
return EINVAL;
if ((error = sys_getrlimit(l, &cup, retval)) != 0)
return error;
rlp = &l->l_proc->p_rlimit[which];
if ((error = copyin(SCARG(&cup, rlp), &rlp, sizeof(rlp))) != 0)
return error;
if (rlp.rlim_cur == RLIM_INFINITY)
if (rlp->rlim_cur == RLIM_INFINITY)
irlp.rlim_cur = IRIX_RLIM64_INFINITY;
else
irlp.rlim_cur = rlp.rlim_cur;
irlp.rlim_cur = rlp->rlim_cur;
if (rlp.rlim_max == RLIM_INFINITY)
if (rlp->rlim_max == RLIM_INFINITY)
irlp.rlim_max = IRIX_RLIM64_INFINITY;
else
irlp.rlim_max = rlp.rlim_cur;
irlp.rlim_max = rlp->rlim_cur;
if ((error = copyout(&irlp, SCARG(uap, rlp), sizeof(irlp))) != 0)
return error;
return 0;
return copyout(&irlp, SCARG(uap, rlp), sizeof(irlp));
}
int
@ -189,15 +171,13 @@ irix_sys_setrlimit(l, v, retval)
syscallarg(int) resource;
syscallarg(const struct irix_rlimit *) rlp;
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_setrlimit_args cup;
struct rlimit rlp;
struct irix_rlimit irlp;
int which;
int error;
SCARG(&cup, which) = irix_to_native_resource(SCARG(uap, resource));
SCARG(&cup, rlp) = stackgap_alloc(p, &sg, sizeof(struct rlimit));
which = irix_to_native_resource(SCARG(uap, resource));
if (which < 0)
return EINVAL;
if ((error = copyin(SCARG(uap, rlp), &irlp, sizeof(irlp))) != 0)
return error;
@ -212,10 +192,7 @@ irix_sys_setrlimit(l, v, retval)
else
rlp.rlim_max = irlp.rlim_cur;
if ((error = sys_setrlimit(l, &cup, retval)) != 0)
return error;
return 0;
return dosetrlimit(l, l->proc, which, &rlp);
}
int
@ -228,15 +205,14 @@ irix_sys_setrlimit64(l, v, retval)
syscallarg(int) resource;
syscallarg(const struct irix_rlimit64 *) rlp;
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_setrlimit_args cup;
struct rlimit rlp;
struct irix_rlimit64 irlp;
int which;
int error;
SCARG(&cup, which) = irix_to_native_resource(SCARG(uap, resource));
SCARG(&cup, rlp) = stackgap_alloc(p, &sg, sizeof(struct rlimit));
which = irix_to_native_resource(SCARG(uap, resource));
if (which < 0)
return EINVAL;
if ((error = copyin(SCARG(uap, rlp), &irlp, sizeof(irlp))) != 0)
return error;
@ -251,8 +227,5 @@ irix_sys_setrlimit64(l, v, retval)
else
rlp.rlim_max = irlp.rlim_cur;
if ((error = sys_setrlimit(l, &cup, retval)) != 0)
return error;
return 0;
return dosetrlimit(l, l->proc, which, &rlp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_misc.c,v 1.175 2007/05/10 21:30:15 christos Exp $ */
/* $NetBSD: linux_misc.c,v 1.176 2007/05/12 21:07:02 dsl Exp $ */
/*-
* Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.175 2007/05/10 21:30:15 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.176 2007/05/12 21:07:02 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ptrace.h"
@ -1550,26 +1550,18 @@ linux_sys_getrlimit(l, v, retval)
syscallarg(struct orlimit *) rlp;
# endif
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_getrlimit_args ap;
struct rlimit rl;
# ifdef LINUX_LARGEFILE64
struct rlimit orl;
# else
struct orlimit orl;
# endif
int error;
int which;
SCARG(&ap, which) = linux_to_bsd_limit(SCARG(uap, which));
if ((error = SCARG(&ap, which)) < 0)
return -error;
SCARG(&ap, rlp) = stackgap_alloc(p, &sg, sizeof rl);
if ((error = sys_getrlimit(l, &ap, retval)) != 0)
return error;
if ((error = copyin(SCARG(&ap, rlp), &rl, sizeof(rl))) != 0)
return error;
bsd_to_linux_rlimit(&orl, &rl);
which = linux_to_bsd_limit(SCARG(uap, which));
if (which < 0)
return -which;
bsd_to_linux_rlimit(&orl, &l->l_proc->p_rlimit[which]);
return copyout(&orl, SCARG(uap, rlp), sizeof(orl));
}
@ -1588,9 +1580,6 @@ linux_sys_setrlimit(l, v, retval)
syscallarg(struct orlimit *) rlp;
# endif
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_getrlimit_args ap;
struct rlimit rl;
# ifdef LINUX_LARGEFILE64
struct rlimit orl;
@ -1598,17 +1587,17 @@ linux_sys_setrlimit(l, v, retval)
struct orlimit orl;
# endif
int error;
int which;
SCARG(&ap, which) = linux_to_bsd_limit(SCARG(uap, which));
SCARG(&ap, rlp) = stackgap_alloc(p, &sg, sizeof rl);
if ((error = SCARG(&ap, which)) < 0)
return -error;
if ((error = copyin(SCARG(uap, rlp), &orl, sizeof(orl))) != 0)
return error;
which = linux_to_bsd_limit(SCARG(uap, which));
if (which < 0)
return -which;
linux_to_bsd_rlimit(&rl, &orl);
if ((error = copyout(&rl, SCARG(&ap, rlp), sizeof(rl))) != 0)
return error;
return sys_setrlimit(l, &ap, retval);
return dosetrlimit(l, l->l_proc, which, &rl);
}
# if !defined(__mips__) && !defined(__amd64__)

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux32_resource.c,v 1.5 2007/03/18 21:38:32 dsl Exp $ */
/* $NetBSD: linux32_resource.c,v 1.6 2007/05/12 21:07:02 dsl Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_resource.c,v 1.5 2007/03/18 21:38:32 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux32_resource.c,v 1.6 2007/05/12 21:07:02 dsl Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_resource.c,v 1.5 2007/03/18 21:38:32 dsl Exp
#include <sys/fcntl.h>
#include <sys/select.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/ucred.h>
#include <sys/swap.h>
@ -80,26 +81,14 @@ linux32_sys_getrlimit(l, v, retval)
syscallarg(int) which;
syscallarg(netbsd32_orlimitp_t) rlp;
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_getrlimit_args ap;
struct orlimit orl;
struct rlimit rl;
int error;
int which;
SCARG(&ap, which) = linux_to_bsd_limit(SCARG(uap, which));
if ((error = SCARG(&ap, which)) < 0)
return -error;
which = linux_to_bsd_limit(SCARG(uap, which));
if (which < 0)
return -which;
SCARG(&ap, rlp) = stackgap_alloc(p, &sg, sizeof rl);
if ((error = sys_getrlimit(l, &ap, retval)) != 0)
return error;
if ((error = copyin(SCARG(&ap, rlp), &rl, sizeof(rl))) != 0)
return error;
bsd_to_linux_rlimit(&orl, &rl);
bsd_to_linux_rlimit(&orl, &l->l_proc->p_rlimit[which]);
return copyout(&orl, SCARG_P32(uap, rlp), sizeof(orl));
}
@ -114,27 +103,21 @@ linux32_sys_setrlimit(l, v, retval)
syscallarg(int) which;
syscallarg(netbsd32_orlimitp_t) rlp;
} */ *uap = v;
struct proc *p = l->l_proc;
void *sg = stackgap_init(p, 0);
struct sys_getrlimit_args ap;
struct rlimit rl;
struct orlimit orl;
int error;
SCARG(&ap, which) = linux_to_bsd_limit(SCARG(uap, which));
SCARG(&ap, rlp) = stackgap_alloc(p, &sg, sizeof rl);
if ((error = SCARG(&ap, which)) < 0)
return -error;
int which;
if ((error = copyin(SCARG_P32(uap, rlp), &orl, sizeof(orl))) != 0)
return error;
which = linux_to_bsd_limit(SCARG(uap, which));
if (which < 0)
return -which;
linux_to_bsd_rlimit(&rl, &orl);
if ((error = copyout(&rl, SCARG(&ap, rlp), sizeof(rl))) != 0)
return error;
return sys_setrlimit(l, &ap, retval);
return dosetrlimit(l, l->l_proc, which, &rl);
}
int