Author: kib
Date: Thu Aug 16 13:04:21 2012
New Revision: 239329
URL: http://svn.freebsd.org/changeset/base/239329

Log:
  As a safety measure, disable lowering pid_max too much.
  
  Requested by: Peter Jeremy <pe...@rulingia.com>
  MFC after:    1 week

Modified:
  head/sys/kern/kern_mib.c
  head/sys/kern/subr_param.c

Modified: head/sys/kern/kern_mib.c
==============================================================================
--- head/sys/kern/kern_mib.c    Thu Aug 16 13:01:56 2012        (r239328)
+++ head/sys/kern/kern_mib.c    Thu Aug 16 13:04:21 2012        (r239329)
@@ -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;

Modified: head/sys/kern/subr_param.c
==============================================================================
--- head/sys/kern/subr_param.c  Thu Aug 16 13:01:56 2012        (r239328)
+++ head/sys/kern/subr_param.c  Thu Aug 16 13:04:21 2012        (r239329)
@@ -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;
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to