Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:06:17 -0000
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r345730 - stable/12/sys/vm
Message-ID:  <201903301003.x2UA3QsA075354@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Mar 30 10:03:26 2019
New Revision: 345730
URL: https://svnweb.freebsd.org/changeset/base/345730

Log:
  MFC r345452:
  ASLR: check for max_addr after applying randomization, not before.

Modified:
  stable/12/sys/vm/vm_map.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/vm/vm_map.c
==============================================================================
--- stable/12/sys/vm/vm_map.c	Sat Mar 30 09:24:06 2019	(r345729)
+++ stable/12/sys/vm/vm_map.c	Sat Mar 30 10:03:26 2019	(r345730)
@@ -1673,11 +1673,12 @@ again:
 			    (max_addr == 0 || max_addr > MAP_32BIT_MAX_ADDR) ?
 			    aslr_pages_rnd_64[pidx] : aslr_pages_rnd_32[pidx];
 			if (vm_map_findspace(map, curr_min_addr, length +
-			    gap * pagesizes[pidx], addr) ||
-			    (max_addr != 0 && *addr + length > max_addr))
+			    gap * pagesizes[pidx], addr))
 				goto again;
 			/* And randomize the start address. */
 			*addr += (arc4random() % gap) * pagesizes[pidx];
+			if (max_addr != 0 && *addr + length > max_addr)
+				goto again;
 		} else if (vm_map_findspace(map, curr_min_addr, length, addr) ||
 		    (max_addr != 0 && *addr + length > max_addr)) {
 			if (cluster) {





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