Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Aug 2017 18:47:24 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r322897 - head/sys/kern
Message-ID:  <201708251847.v7PIlOxV018386@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Fri Aug 25 18:47:23 2017
New Revision: 322897
URL: https://svnweb.freebsd.org/changeset/base/322897

Log:
  Correct a regression in the previous change, r322459.  Specifically, the
  removal of the "blk" parameter from blst_meta_alloc() had the unintended
  effect of generating an out-of-range allocation when the cursor reaches
  the end of the tree if the number of managed blocks in the tree equals
  the so-called "radix" (which in the blist code is not the standard notion
  of what a radix is but rather the maximum number of leaves in a tree of
  the current height.)  In other words, only certain swap configurations
  were affected, which is why earlier testing did not reveal the problem.
  
  Submitted by:	Doug Moore <dougm@rice.edu>
  Reported by:	pho, kib
  Tested by:	pho
  X-MFC with:	r322459
  Differential Revision:	https://reviews.freebsd.org/D12106

Modified:
  head/sys/kern/subr_blist.c

Modified: head/sys/kern/subr_blist.c
==============================================================================
--- head/sys/kern/subr_blist.c	Fri Aug 25 17:29:48 2017	(r322896)
+++ head/sys/kern/subr_blist.c	Fri Aug 25 18:47:23 2017	(r322897)
@@ -251,6 +251,8 @@ blist_alloc(blist_t bl, daddr_t count)
 		    bl->bl_radix);
 		if (blk != SWAPBLK_NONE) {
 			bl->bl_cursor = blk + count;
+			if (bl->bl_cursor == bl->bl_blocks)
+				bl->bl_cursor = 0;
 			return (blk);
 		} else if (bl->bl_cursor != 0)
 			bl->bl_cursor = 0;



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