1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/arch/x86/platform/efi
Ard Biesheuvel 75dde792d6 efi/x86: Free EFI memory map only when installing a new one.
The logic in __efi_memmap_init() is shared between two different
execution flows:
- mapping the EFI memory map early or late into the kernel VA space, so
  that its entries can be accessed;
- the x86 specific cloning of the EFI memory map in order to insert new
  entries that are created as a result of making a memory reservation
  via a call to efi_mem_reserve().

In the former case, the underlying memory containing the kernel's view
of the EFI memory map (which may be heavily modified by the kernel
itself on x86) is not modified at all, and the only thing that changes
is the virtual mapping of this memory, which is different between early
and late boot.

In the latter case, an entirely new allocation is created that carries a
new, updated version of the kernel's view of the EFI memory map. When
installing this new version, the old version will no longer be
referenced, and if the memory was allocated by the kernel, it will leak
unless it gets freed.

The logic that implements this freeing currently lives on the code path
that is shared between these two use cases, but it should only apply to
the latter. So move it to the correct spot.

While at it, drop the dummy definition for non-x86 architectures, as
that is no longer needed.

Cc: <stable@vger.kernel.org>
Fixes: f0ef652347 ("efi: Fix efi_memmap_alloc() leaks")
Tested-by: Ashish Kalra <Ashish.Kalra@amd.com>
Link: https://lore.kernel.org/all/36ad5079-4326-45ed-85f6-928ff76483d3@amd.com
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-06-15 10:25:02 +02:00
..
efi.c x86/efi: Implement arch_ima_efi_boot_mode() in source file 2024-01-30 15:17:17 +01:00
efi_32.c efi/x86: Move EFI runtime call setup/teardown helpers out of line 2023-09-11 06:37:50 +00:00
efi_64.c efi/x86: Move EFI runtime call setup/teardown helpers out of line 2023-09-11 06:37:50 +00:00
efi_stub_32.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
efi_stub_64.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
efi_thunk_64.S efi/x86-mixed: move unmitigated RET into .rodata 2022-08-16 09:28:05 +02:00
fake_mem.c efi: memmap: Move EFI fake memmap support into x86 arch tree 2022-11-18 09:14:09 +01:00
Makefile efi: x86: Move EFI runtime map sysfs code to arch/x86 2022-11-18 09:14:09 +01:00
memmap.c efi/x86: Free EFI memory map only when installing a new one. 2024-06-15 10:25:02 +02:00
quirks.c efivarfs: expose used and total size 2023-05-17 18:21:34 +02:00
runtime-map.c efi: x86: make kobj_type structure constant 2023-05-10 19:00:40 +02:00