Author: mjg
Date: Sat Dec  8 10:22:12 2018
New Revision: 341723
URL: https://svnweb.freebsd.org/changeset/base/341723

Log:
  Fix a corner case in ID bitmap management.
  
  If all IDs from trypid to pid_max were used as pids, the code would enter
  a loop which would be infinite if none of the IDs could become free (e.g.
  they all belong to processes which did not transitioned to zombie).
  
  Fixes:        r341684 ("Manage process-related IDs with bitmaps")
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/kern_fork.c

Modified: head/sys/kern/kern_fork.c
==============================================================================
--- head/sys/kern/kern_fork.c   Sat Dec  8 06:34:12 2018        (r341722)
+++ head/sys/kern/kern_fork.c   Sat Dec  8 10:22:12 2018        (r341723)
@@ -273,8 +273,10 @@ retry:
        }
 
        bit_ffc_at(&proc_id_pidmap, trypid, pid_max, &result);
-       if (result == -1)
+       if (result == -1) {
+               trypid = 100;
                goto retry;
+       }
        if (bit_test(&proc_id_grpidmap, result) ||
            bit_test(&proc_id_sessidmap, result) ||
            bit_test(&proc_id_reapmap, result)) {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to