[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/6] relocator: Do not use memory region if its starta is
From: |
Andrei Borzenkov |
Subject: |
Re: [PATCH v2 2/6] relocator: Do not use memory region if its starta is smaller than size |
Date: |
Tue, 21 Jul 2015 09:42:10 +0300 |
On Mon, Jul 20, 2015 at 5:35 PM, Daniel Kiper <address@hidden> wrote:
> malloc_in_range() should not use memory region if its starta is smaller
> than size. Otherwise target wraps around and points to region which is
> usually not a RAM, e.g.:
>
> loader/multiboot.c:93: segment 0: paddr=0x800000, memsz=0x3f800000,
> vaddr=0x800000
> lib/relocator.c:1241: min_addr = 0x0, max_addr = 0xffffffffffffffff, target =
> 0x800000
> lib/relocator.c:434: trying to allocate in 0x800000-0xffffffffffffffff
> aligned 0x1 size 0x3f800000
> lib/relocator.c:434: trying to allocate in 0x0-0x800000 aligned 0x1 size
> 0x3f800000
> lib/relocator.c:434: trying to allocate in 0x0-0xffffffffffffffff aligned 0x1
> size 0x3f800000
> lib/relocator.c:1188: allocated: 0xffffffffc07fffff+0x3f800000
> lib/relocator.c:1277: allocated 0xffffffffc07fffff/0x800000
>
> Signed-off-by: Daniel Kiper <address@hidden>
> ---
> grub-core/lib/relocator.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
> index f759c7f..4eee0c5 100644
> --- a/grub-core/lib/relocator.c
> +++ b/grub-core/lib/relocator.c
> @@ -748,7 +748,7 @@ malloc_in_range (struct grub_relocator *rel,
> /* Found an usable address. */
> goto found;
> }
> - if (isinsidebefore && !isinsideafter && !from_low_priv)
> + if (isinsidebefore && !isinsideafter && !from_low_priv && starta >=
> size)
That's too late, we need to check end of region on previous iteration.
Consider region of 128 bytes, requested size 129 and alignment 256.
Than starta still ends up high in memory.
> {
> target = starta - size;
> if (target > end - size)
> --
> 1.7.10.4
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel
- [PATCH v2 0/6] multiboot2: Add two extensions and fix some issues, Daniel Kiper, 2015/07/20
- [PATCH v2 2/6] relocator: Do not use memory region if its starta is smaller than size, Daniel Kiper, 2015/07/20
- Re: [PATCH v2 2/6] relocator: Do not use memory region if its starta is smaller than size,
Andrei Borzenkov <=
- [PATCH v2 3/6] i386/relocator: Add grub_relocator64_efi relocator, Daniel Kiper, 2015/07/20
- [PATCH v2 4/6] multiboot2: Add tags used to pass ImageHandle to loaded image, Daniel Kiper, 2015/07/20
- [PATCH v2 5/6] multiboot2: Add support for relocatable images, Daniel Kiper, 2015/07/20
- [PATCH v2 1/6] gitignore: Ignore *.orig, *.rej and *.swp files, Daniel Kiper, 2015/07/20
- [PATCH v2 6/6] multiboot2: Do not pass memory maps to image if EFI boot services are enabled, Daniel Kiper, 2015/07/20