aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1994-12-06 22:53:37 +0000
committerBruce Evans <bde@FreeBSD.org>1994-12-06 22:53:37 +0000
commita81b757af0da2d70b04d064810b0f7f3591d4fd7 (patch)
tree7b38f8d9c0850d444a93f07c61206b5f62e45641 /sys/kern/kern_resource.c
parenta2a65bbb149464ed66141f6afa4736b552e9875f (diff)
downloadsrc-a81b757af0da2d70b04d064810b0f7f3591d4fd7.tar.gz
src-a81b757af0da2d70b04d064810b0f7f3591d4fd7.zip
Don't allow negative limits at all. Convert them to RLIM_INFINITY instead
of returning EINVAL since something may depend on them being broken. Allowing negative limits caused bugs almost everywhere. The recent fixes for MAXSSIZ checked the limits too late to stop anyone defeating limits set by root...
Notes
Notes: svn path=/head/; revision=5009
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 846076b592f1..414bc1a8c45c 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
- * $Id: kern_resource.c,v 1.8 1994/12/01 20:20:21 ats Exp $
+ * $Id: kern_resource.c,v 1.9 1994/12/02 23:00:40 ats Exp $
*/
#include <sys/param.h>
@@ -346,6 +346,15 @@ dosetrlimit(p, which, limp)
if (which >= RLIM_NLIMITS)
return (EINVAL);
alimp = &p->p_rlimit[which];
+
+ /*
+ * Preserve historical bugs by treating negative limits as unsigned.
+ */
+ if (limp->rlim_cur < 0)
+ limp->rlim_cur = RLIM_INFINITY;
+ if (limp->rlim_max < 0)
+ limp->rlim_max = RLIM_INFINITY;
+
if (limp->rlim_cur > alimp->rlim_max ||
limp->rlim_max > alimp->rlim_max)
if ((error = suser(p->p_ucred, &p->p_acflag)))
@@ -362,16 +371,16 @@ dosetrlimit(p, which, limp)
switch (which) {
case RLIMIT_DATA:
- if ((u_quad_t) limp->rlim_cur > MAXDSIZ)
+ if (limp->rlim_cur > MAXDSIZ)
limp->rlim_cur = MAXDSIZ;
- if ((u_quad_t) limp->rlim_max > MAXDSIZ)
+ if (limp->rlim_max > MAXDSIZ)
limp->rlim_max = MAXDSIZ;
break;
case RLIMIT_STACK:
- if ((u_quad_t) limp->rlim_cur > MAXSSIZ)
+ if (limp->rlim_cur > MAXSSIZ)
limp->rlim_cur = MAXSSIZ;
- if ((u_quad_t) limp->rlim_max > MAXSSIZ)
+ if (limp->rlim_max > MAXSSIZ)
limp->rlim_max = MAXSSIZ;
/*
* Stack is allocated to the max at exec time with only
@@ -383,7 +392,7 @@ dosetrlimit(p, which, limp)
vm_size_t size;
vm_prot_t prot;
- if ((u_quad_t) limp->rlim_cur > (u_quad_t) alimp->rlim_cur) {
+ if (limp->rlim_cur > alimp->rlim_cur) {
prot = VM_PROT_ALL;
size = limp->rlim_cur - alimp->rlim_cur;
addr = USRSTACK - limp->rlim_cur;