summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_mib.c8
-rw-r--r--sys/kern/subr_param.c3
2 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index f6ab3a4..b0bc5c8 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -510,8 +510,12 @@ sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS)
return (error);
sx_xlock(&proctree_lock);
sx_xlock(&allproc_lock);
- /* Only permit the values less then PID_MAX. */
- if (pm > PID_MAX)
+
+ /*
+ * Only permit the values less then PID_MAX.
+ * As a safety measure, do not allow to limit the pid_max too much.
+ */
+ if (pm < 300 || pm > PID_MAX)
error = EINVAL;
else
pid_max = pm;
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
index 1c6b867..c4a566d 100644
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -255,10 +255,13 @@ init_param1(void)
/*
* Only allow to lower the maximal pid.
+ * Prevent setting up a non-bootable system if pid_max is too low.
*/
TUNABLE_INT_FETCH("kern.pid_max", &pid_max);
if (pid_max > PID_MAX)
pid_max = PID_MAX;
+ else if (pid_max < 300)
+ pid_max = 300;
}
/*
OpenPOWER on IntegriCloud