Skip to contentSkip to conversation

efi/boot: Avoid memory corruption when freeing ebmalloc area

PATCH In review Andrew Cooper 2 participants 2 messages Feb 28, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/boot: Avoid memory corruption when freeing ebmalloc area

Don't free the final page containing a partial allocation.

---
CC: Jan Beulich <[email protected]>

NB: This was from code inspection. It is not whatever is causing the bisector to finger this commit.

---
 xen/common/efi/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/efi/boot.c +1 -1
index b6cbdad..f89163c 100644
@@ -148,7 +148,7 @@ static void __init __maybe_unused free_ebmalloc_unused_mem(void)
 {
     unsigned long start, end;
 
-    start = (unsigned long)ebmalloc_mem + PAGE_ALIGN(ebmalloc_allocated);
+    start = (unsigned long)ebmalloc_mem + ROUNDUP(ebmalloc_allocated, PAGE_SIZE);
     end = (unsigned long)ebmalloc_mem + sizeof(ebmalloc_mem);
 
     destroy_xen_mappings(start, end);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

xen/common/efi/boot.c static void __init __maybe_unused free_ebmalloc_unused_mem(void) · line 151

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 28.02.17 at 12:44, <[email protected]> wrote:
xen/common/efi/boot.c +1 -1
@@ -148,7 +148,7 @@ static void __init __maybe_unused free_ebmalloc_unused_mem(void)
 {
     unsigned long start, end;
 
-    start = (unsigned long)ebmalloc_mem + PAGE_ALIGN(ebmalloc_allocated);
+    start = (unsigned long)ebmalloc_mem + ROUNDUP(ebmalloc_allocated, PAGE_SIZE);

With

#define PAGE_ALIGN(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK)

I don't see any behavioral change with your adjustment.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel