grub2/grub-core/kern/efi
Darren Kenny 6aee4bfd69 kern/efi/mm: Fix possible NULL pointer dereference
The model of grub_efi_get_memory_map() is that if memory_map is NULL,
then the purpose is to discover how much memory should be allocated to
it for the subsequent call.

The problem here is that with grub_efi_is_finished set to 1, there is no
check at all that the function is being called with a non-NULL memory_map.

While this MAY be true, we shouldn't assume it.

The solution to this is to behave as expected, and if memory_map is NULL,
then don't try to use it and allow memory_map_size to be filled in, and
return 0 as is done later in the code if the buffer is too small (or NULL).

Additionally, drop unneeded ret = 1.

Fixes: CID 96632

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-03-02 15:54:16 +01:00
..
acpi.c tsc: Use alternative delay sources whenever appropriate. 2015-11-27 11:39:55 +01:00
efi.c kern/efi: Fix memory leak on failure 2021-03-02 15:54:16 +01:00
fdt.c efi: Move fdt helper into own file 2016-11-24 10:09:24 +01:00
init.c efi: Lockdown the GRUB when the UEFI Secure Boot is enabled 2021-03-02 15:54:15 +01:00
mm.c kern/efi/mm: Fix possible NULL pointer dereference 2021-03-02 15:54:16 +01:00
sb.c efi: Use grub_is_lockdown() instead of hardcoding a disabled modules list 2021-03-02 15:54:15 +01:00