summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mib.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/kern_mib.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/kern_mib.c')
-rw-r--r--sys/kern/kern_mib.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index 75b3af9..f6ab3a4 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -499,6 +499,30 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD,
SYSCTL_INT(_debug_sizeof, OID_AUTO, proc, CTLFLAG_RD,
0, sizeof(struct proc), "sizeof(struct proc)");
+static int
+sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS)
+{
+ int error, pm;
+
+ pm = pid_max;
+ error = sysctl_handle_int(oidp, &pm, 0, req);
+ if (error || !req->newptr)
+ return (error);
+ sx_xlock(&proctree_lock);
+ sx_xlock(&allproc_lock);
+ /* Only permit the values less then PID_MAX. */
+ if (pm > PID_MAX)
+ error = EINVAL;
+ else
+ pid_max = pm;
+ sx_xunlock(&allproc_lock);
+ sx_xunlock(&proctree_lock);
+ return (error);
+}
+SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN |
+ CTLFLAG_MPSAFE, 0, 0, sysctl_kern_pid_max, "I",
+ "Maximum allowed pid");
+
#include <sys/bio.h>
#include <sys/buf.h>
SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD,
OpenPOWER on IntegriCloud