summaryrefslogtreecommitdiff
path: root/sys/kern/subr_param.c
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2010-01-12 07:49:34 +0000
committerBrooks Davis <brooks@FreeBSD.org>2010-01-12 07:49:34 +0000
commit412f9500e2fd3ae0c7546fefb5823bc207139213 (patch)
treede91cf4c019f8024f0f1e02debf82cece77d60f2 /sys/kern/subr_param.c
parent7bf27b2dde45e09ea60028de94ccabdc8bd1d1d3 (diff)
Notes
Diffstat (limited to 'sys/kern/subr_param.c')
-rw-r--r--sys/kern/subr_param.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
index 6113b6397321..fcd8131d4b08 100644
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include "opt_param.h"
#include "opt_maxusers.h"
+#include <sys/limits.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -88,6 +89,7 @@ int maxfiles; /* sys. wide open files limit */
int maxfilesperproc; /* per-proc open files limit */
int ncallout; /* maximum # of timer events */
int nbuf;
+int ngroups_max; /* max # groups per process */
int nswbuf;
long maxswzone; /* max swmeta KVA storage */
long maxbcache; /* max buffer cache KVA storage */
@@ -228,6 +230,18 @@ init_param1(void)
TUNABLE_ULONG_FETCH("kern.maxssiz", &maxssiz);
sgrowsiz = SGROWSIZ;
TUNABLE_ULONG_FETCH("kern.sgrowsiz", &sgrowsiz);
+
+ /*
+ * Let the administrator set {NGROUPS_MAX}, but disallow values
+ * less than NGROUPS_MAX which would violate POSIX.1-2008 or
+ * greater than INT_MAX-1 which would result in overflow.
+ */
+ ngroups_max = NGROUPS_MAX;
+ TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max);
+ if (ngroups_max < NGROUPS_MAX)
+ ngroups_max = NGROUPS_MAX;
+ if (ngroups_max > INT_MAX - 1)
+ ngroups_max = INT_MAX - 1;
}
/*