]> xenbits.xensource.com Git - xen.git/commitdiff
hvmloader: fix scratch_alloc to avoid overlaps
authorAnthony PERARD <anthony.perard@citrix.com>
Wed, 10 Feb 2016 13:46:45 +0000 (14:46 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 10 Feb 2016 13:46:45 +0000 (14:46 +0100)
scratch_alloc() set scratch_start to the last byte of the current
allocation.  The value of scratch_start is then reused as is (if it is
already aligned) in the next allocation.  This result in a potential reuse
of the last byte of the previous allocation.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/firmware/hvmloader/util.c

index d779fd75b6d83bdb3cf9d6dfcb1825ede44a646e..938270964cb98acfcf126f2fc02ecced7308fefc 100644 (file)
@@ -478,7 +478,7 @@ void *scratch_alloc(uint32_t size, uint32_t align)
     if ( align < 16 )
         align = 16;
 
-    s = (scratch_start + align - 1) & ~(align - 1);
+    s = (scratch_start + align) & ~(align - 1);
     e = s + size - 1;
 
     BUG_ON(e < s);