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;
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to