[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86: If e820 map overflows, leak memory in a safe manner.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1190908252 -3600
# Node ID 9c567284436e367c5ffbcd697a94ec36c3dbe27b
# Parent  04cc0e22a20a0bdf6ceefb016185175ee094ed30
x86: If e820 map overflows, leak memory in a safe manner.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/e820.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff -r 04cc0e22a20a -r 9c567284436e xen/arch/x86/e820.c
--- a/xen/arch/x86/e820.c       Thu Sep 27 16:36:23 2007 +0100
+++ b/xen/arch/x86/e820.c       Thu Sep 27 16:50:52 2007 +0100
@@ -416,11 +416,9 @@ int __init reserve_e820_ram(struct e820m
         /* Truncate end. */
         e820->map[i].size -= e - s;
     }
-    else
+    else if ( e820->nr_map < ARRAY_SIZE(e820->map) )
     {
         /* Split in two. */
-        if ( e820->nr_map >= ARRAY_SIZE(e820->map) )
-            return 0;
         memmove(&e820->map[i+1], &e820->map[i],
                 (e820->nr_map-i) * sizeof(e820->map[0]));
         e820->nr_map++;
@@ -429,6 +427,21 @@ int __init reserve_e820_ram(struct e820m
         e820->map[i].addr = e;
         e820->map[i].size = re - e;
     }
+    else
+    {
+        /* e820map is at maximum size. We have to leak some space. */
+        if ( (s - rs) > (re - e) )
+        {
+            printk("e820 overflow: leaking RAM %"PRIx64"-%"PRIx64"\n", e, re);
+            e820->map[i].size = s - rs;
+        }
+        else
+        {
+            printk("e820 overflow: leaking RAM %"PRIx64"-%"PRIx64"\n", rs, s);
+            e820->map[i].addr = e;
+            e820->map[i].size = re - e;
+        }
+    }
 
     return 1;
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.