Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Dec 2018 10:22:13 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341723 - head/sys/kern
Message-ID:  <201812081022.wB8AMD8J030348@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812081022.wB8AMD8J030348>