summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2013-04-01 01:07:34 +0000
committerguenther <guenther@openbsd.org>2013-04-01 01:07:34 +0000
commitaea7ebe1970baf8fbc80bccc4040da46c07eeba9 (patch)
tree3f5037af222dd649d6de464332a3830c33d83962 /sys/kern/kern_resource.c
parentDo not depend on the value of PATH to run. (diff)
downloadwireguard-openbsd-aea7ebe1970baf8fbc80bccc4040da46c07eeba9.tar.xz
wireguard-openbsd-aea7ebe1970baf8fbc80bccc4040da46c07eeba9.zip
Make setrlimit() return EINVAL if rlim_cur > rlim_max, per POSIX.
Use limfree() instead of decrementing the reference counter directly. ok kettenis@
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 995b3db15ef..ea4f8bf512b 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_resource.c,v 1.40 2012/04/10 15:50:52 guenther Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.41 2013/04/01 01:07:34 guenther Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
@@ -236,12 +236,11 @@ dosetrlimit(struct proc *p, u_int which, struct rlimit *limp)
rlim_t maxlim;
int error;
- if (which >= RLIM_NLIMITS)
+ if (which >= RLIM_NLIMITS || limp->rlim_cur > limp->rlim_max)
return (EINVAL);
alimp = &p->p_rlimit[which];
- if (limp->rlim_cur > alimp->rlim_max ||
- limp->rlim_max > alimp->rlim_max)
+ if (limp->rlim_max > alimp->rlim_max)
if ((error = suser(p, 0)) != 0)
return (error);
if (p->p_p->ps_limit->p_refcnt > 1) {
@@ -249,7 +248,7 @@ dosetrlimit(struct proc *p, u_int which, struct rlimit *limp)
/* limcopy() can sleep, so copy before decrementing refcnt */
p->p_p->ps_limit = limcopy(l);
- l->p_refcnt--;
+ limfree(l);
alimp = &p->p_rlimit[which];
}