|
|
80913e |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
80913e |
From: Alexey Makhalov <amakhalov@vmware.com>
|
|
|
80913e |
Date: Fri, 17 Jul 2020 05:17:26 +0000
|
|
|
80913e |
Subject: [PATCH] relocator: Fix grub_relocator_alloc_chunk_align() top memory
|
|
|
80913e |
allocation
|
|
|
80913e |
|
|
|
80913e |
Current implementation of grub_relocator_alloc_chunk_align()
|
|
|
80913e |
does not allow allocation of the top byte.
|
|
|
80913e |
|
|
|
80913e |
Assuming input args are:
|
|
|
80913e |
max_addr = 0xfffff000;
|
|
|
80913e |
size = 0x1000;
|
|
|
80913e |
|
|
|
80913e |
And this is valid. But following overflow protection will
|
|
|
80913e |
unnecessarily move max_addr one byte down (to 0xffffefff):
|
|
|
80913e |
if (max_addr > ~size)
|
|
|
80913e |
max_addr = ~size;
|
|
|
80913e |
|
|
|
80913e |
~size + 1 will fix the situation. In addition, check size
|
|
|
80913e |
for non zero to do not zero max_addr.
|
|
|
80913e |
|
|
|
80913e |
Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
|
|
|
80913e |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
80913e |
Upstream-commit-id: ab80a97eb1f
|
|
|
80913e |
---
|
|
|
80913e |
grub-core/lib/relocator.c | 4 ++--
|
|
|
80913e |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
80913e |
|
|
|
80913e |
diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
|
|
|
b32e65 |
index 5847aac36..f2c1944c2 100644
|
|
|
80913e |
--- a/grub-core/lib/relocator.c
|
|
|
80913e |
+++ b/grub-core/lib/relocator.c
|
|
|
80913e |
@@ -1386,8 +1386,8 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
|
|
|
80913e |
};
|
|
|
80913e |
grub_addr_t min_addr2 = 0, max_addr2;
|
|
|
80913e |
|
|
|
80913e |
- if (max_addr > ~size)
|
|
|
80913e |
- max_addr = ~size;
|
|
|
80913e |
+ if (size && (max_addr > ~size))
|
|
|
80913e |
+ max_addr = ~size + 1;
|
|
|
80913e |
|
|
|
80913e |
#ifdef GRUB_MACHINE_PCBIOS
|
|
|
80913e |
if (min_addr < 0x1000)
|