svn commit: r294238 - head/sys/arm/arm

Andrew Turner andrew at FreeBSD.org
Mon Jan 18 00:07:06 UTC 2016


Author: andrew
Date: Mon Jan 18 00:07:04 2016
New Revision: 294238
URL: https://svnweb.freebsd.org/changeset/base/294238

Log:
  Add extra checks to make sure the size is valid. We may get an integer
  underflow when we have small blocks of memory at the start and end of the
  32-bit address range.
  
  While here, only insert mappings pointing at a non-zero amount of memory.
  
  Sponsored by:	ABT Systems Ltd

Modified:
  head/sys/arm/arm/physmem.c

Modified: head/sys/arm/arm/physmem.c
==============================================================================
--- head/sys/arm/arm/physmem.c	Sun Jan 17 23:03:21 2016	(r294237)
+++ head/sys/arm/arm/physmem.c	Mon Jan 18 00:07:04 2016	(r294238)
@@ -292,9 +292,13 @@ arm_physmem_hardware_region(vm_paddr_t p
 	 * than leave some folks with an unusable system while we investigate.
 	 */
 	if (pa == 0) {
+		if (sz <= PAGE_SIZE)
+			return;
 		pa  = PAGE_SIZE;
 		sz -= PAGE_SIZE;
 	} else if (pa + sz == 0) {
+		if (sz <= 1024 * 1024)
+			return;
 		sz -= 1024 * 1024;
 	}
 
@@ -306,7 +310,7 @@ arm_physmem_hardware_region(vm_paddr_t p
 	pa  = round_page(pa);
 	sz  = trunc_page(sz - adj);
 
-	if (hwcnt < nitems(hwregions))
+	if (sz > 0 && hwcnt < nitems(hwregions))
 		insert_region(hwregions, hwcnt++, pa, sz, 0);
 }
 


More information about the svn-src-head mailing list