summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_param.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-08-15 15:56:21 +0000
committerkib <kib@FreeBSD.org>2012-08-15 15:56:21 +0000
commit604f552e40a9a201162d6c070fd96bc504b30ff3 (patch)
treea9682200639371dd135caf82e8d5130aa117d0c2 /sys/kern/subr_param.c
parentba66fb6ab507c9347d6b74704834eddfad52ed48 (diff)
downloadFreeBSD-src-604f552e40a9a201162d6c070fd96bc504b30ff3.zip
FreeBSD-src-604f552e40a9a201162d6c070fd96bc504b30ff3.tar.gz
Add a sysctl kern.pid_max, which limits the maximum pid the system is
allowed to allocate, and corresponding tunable with the same name. Note that existing processes with higher pids are left intact. MFC after: 1 week
Diffstat (limited to 'sys/kern/subr_param.c')
-rw-r--r--sys/kern/subr_param.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
index 8c13336..1c6b867 100644
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -41,12 +41,13 @@ __FBSDID("$FreeBSD$");
#include "opt_msgbuf.h"
#include "opt_maxusers.h"
-#include <sys/limits.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/sysctl.h>
+#include <sys/limits.h>
#include <sys/msgbuf.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -92,6 +93,7 @@ int ncallout; /* maximum # of timer events */
int nbuf;
int ngroups_max; /* max # groups per process */
int nswbuf;
+pid_t pid_max = PID_MAX;
long maxswzone; /* max swmeta KVA storage */
long maxbcache; /* max buffer cache KVA storage */
long maxpipekva; /* Limit on pipe KVA */
@@ -250,6 +252,13 @@ init_param1(void)
TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max);
if (ngroups_max < NGROUPS_MAX)
ngroups_max = NGROUPS_MAX;
+
+ /*
+ * Only allow to lower the maximal pid.
+ */
+ TUNABLE_INT_FETCH("kern.pid_max", &pid_max);
+ if (pid_max > PID_MAX)
+ pid_max = PID_MAX;
}
/*
OpenPOWER on IntegriCloud