svn commit: r212165 - head/sys/boot/ofw/libofw

Nathan Whitehorn nwhitehorn at FreeBSD.org
Thu Sep 2 22:26:50 UTC 2010


Author: nwhitehorn
Date: Thu Sep  2 22:26:49 2010
New Revision: 212165
URL: http://svn.freebsd.org/changeset/base/212165

Log:
  In the case of non-sequential mappings, ofw_mapmem() could ask Open
  Firmware to map a memory region with negative length, causing crashes
  and Undefined Behavior. Add the appropriate check to make the behavior
  defined.

Modified:
  head/sys/boot/ofw/libofw/ofw_copy.c

Modified: head/sys/boot/ofw/libofw/ofw_copy.c
==============================================================================
--- head/sys/boot/ofw/libofw/ofw_copy.c	Thu Sep  2 21:52:43 2010	(r212164)
+++ head/sys/boot/ofw/libofw/ofw_copy.c	Thu Sep  2 22:26:49 2010	(r212165)
@@ -68,7 +68,7 @@ ofw_mapmem(vm_offset_t dest, const size_
 	/*
 	 * Trim area covered by existing mapping, if any
 	 */
-	if (dest < (last_dest + last_len)) {
+	if (dest < (last_dest + last_len) && dest >= last_dest) {
 		nlen -= (last_dest + last_len) - dest;
 		dest = last_dest + last_len;
 	}


More information about the svn-src-head mailing list