grub/grub-core/lib/i386
Alexey Makhalov 61ff5602fe relocator: Protect grub_relocator_alloc_chunk_align() max_addr against integer underflow
This commit introduces integer underflow mitigation in max_addr calculation
in grub_relocator_alloc_chunk_align() invocation.

It consists of 2 fixes:
  1. Introduced grub_relocator_alloc_chunk_align_safe() wrapper function to perform
     sanity check for min/max and size values, and to make safe invocation of
     grub_relocator_alloc_chunk_align() with validated max_addr value. Replace all
     invocations such as grub_relocator_alloc_chunk_align(..., min_addr, max_addr - size, size, ...)
     by grub_relocator_alloc_chunk_align_safe(..., min_addr, max_addr, size, ...).
  2. Introduced UP_TO_TOP32(s) macro for the cases where max_addr is 32-bit top
     address (0xffffffff - size + 1) or similar.

Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:48 +02:00
..
pc Add const keyword to grub_env_get and gettextize week days. 2011-11-11 20:34:37 +01:00
xen xen: Fix wrong register in relocator. 2017-03-05 10:07:36 +01:00
backtrace.c backtrace: Fix register call syntax 2015-12-31 14:54:48 +01:00
halt.c asm: Replace "__asm__ __volatile__" with "asm volatile" 2019-03-12 20:04:07 +01:00
random.c Add RNG module. 2016-02-12 12:39:38 +01:00
reboot.c i386: Don't include lib/i386/reset.c in EFI builds 2018-07-25 14:18:11 +02:00
reboot_trampoline.S * grub-core/kern/i386/pc/startup.S (grub_exit): Add missing zeroing-out. 2011-10-23 23:04:57 +02:00
relocator.c relocator: Protect grub_relocator_alloc_chunk_align() max_addr against integer underflow 2020-07-29 16:55:48 +02:00
relocator16.S freedos: Fix FreeDOS command booting large files (near or above 64 KiB) 2020-01-28 21:16:48 +01:00
relocator32.S Zero %ebp and %edi when entering Linux's 32-bit entry point, as 2010-09-02 22:36:09 +01:00
relocator64.S i386/relocator: Align stack in grub_relocator64_efi relocator 2017-02-02 22:24:47 +01:00
relocator_asm.S Merge mainline into newreloc. For now without boot tests 2010-08-25 03:25:18 +02:00
relocator_common.S * grub-core/lib/i386/relocator_common.S [__APPLE__ && __x86_64__]: Use 2013-11-11 23:02:51 +01:00
relocator_common_c.c Add new ports: i386-xen and x86_64-xen. This allows running GRUB in 2013-11-09 21:29:11 +01:00
setjmp.S * include/grub/dl.h: Switch from APPLE_CC to __APPLE__. 2012-02-29 14:51:09 +01:00