]> git.ipfire.org Git - thirdparty/grub.git/commit
lib/relocator: Always enforce the requested alignment in malloc_in_range()
authorRoger Pau Monné <roger.pau@citrix.com>
Fri, 12 May 2023 07:33:55 +0000 (09:33 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 17 May 2023 16:19:02 +0000 (18:19 +0200)
commit4127ea3a9ae0831018d48d91003389e57e47708f
treec8e417171b9928b16ca6fc305b7fb12bce5a62f4
parent260a9eab46e303bda1a0ae590e549dc5373e29a7
lib/relocator: Always enforce the requested alignment in malloc_in_range()

On failure to allocate from grub_relocator_firmware_alloc_region() in
malloc_in_range() the function would stop enforcing the alignment, and
the following was returned:

  lib/relocator.c:431: trying to allocate in 0x200000-0xffbf9fff aligned 0x200000 size 0x406000
  lib/relocator.c:1197: allocated: 0x74de2000+0x406000
  lib/relocator.c:1407: allocated 0x74de2000/0x74de2000

Fix this by making sure that target always contains a suitably aligned
address. After the change the return from the function is:

  lib/relocator.c:431: trying to allocate in 0x200000-0xffb87fff aligned 0x200000 size 0x478000
  lib/relocator.c:1204: allocated: 0x74c00000+0x478000
  lib/relocator.c:1414: allocated 0x74c00000/0x74c00000

Fixes: 3a5768645c05 (First version of allocation from firmware)
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/lib/relocator.c