linux/arch
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
..
alpha mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
arc bpf-for-netdev 2024-05-27 16:26:30 -07:00
arm efi/arm: Disable LPAE PAN when calling EFI runtime services 2024-06-15 10:25:02 +02:00
arm64 16 hotfixes, 11 of which are cc:stable. 2024-05-25 15:10:33 -07:00
csky The usual shower of singleton fixes and minor series all over MM, 2024-05-19 09:21:03 -07:00
hexagon hexagon: vmlinux.lds.S: handle attributes section 2024-03-26 11:07:23 -07:00
loongarch - A series ("kbuild: enable more warnings by default") from Arnd 2024-05-22 18:59:29 -07:00
m68k mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
microblaze mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
mips mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
nios2 Kbuild updates for v6.10 2024-05-18 12:39:20 -07:00
openrisc openrisc: Move FPU state out of pt_regs 2024-04-15 15:20:39 +01:00
parisc mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
powerpc powerpc: Limit ARCH_HAS_KERNEL_FPU_SUPPORT to PPC64 2024-05-30 22:57:27 +10:00
riscv riscv: Fix fully ordered LR/SC xchg[8|16]() implementations 2024-05-30 09:43:14 -07:00
s390 mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
sh mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
sparc Jeff Xu's implementation of the mseal() syscall. 2024-05-24 12:47:28 -07:00
um This pull request contains the following changes for UML: 2024-05-25 13:17:48 -07:00
x86 efi/x86: Free EFI memory map only when installing a new one. 2024-06-15 10:25:02 +02:00
xtensa mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
.gitignore
Kconfig arch: add ARCH_HAS_KERNEL_FPU_SUPPORT 2024-05-19 14:36:17 -07:00