From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7F3NP CVE: NA
--------------------------------
Efi fake mem support for arm64 is introduced for debug propose only. However efi_memmap_init_late in arm_enable_runtime_services will free this memory which will lead to UAF on efi.memmap.map.
In order to slove this, clear efi.memmap.flags to skip free. Since efi map is never freed in arm64, this will not lead to memroy leak.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- drivers/firmware/efi/fake_mem.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/drivers/firmware/efi/fake_mem.c b/drivers/firmware/efi/fake_mem.c index 6e0f34a38171..be7d13ef91d2 100644 --- a/drivers/firmware/efi/fake_mem.c +++ b/drivers/firmware/efi/fake_mem.c @@ -61,6 +61,19 @@ static void __init efi_fake_range(struct efi_mem_range *efi_range) /* swap into new EFI memmap */ early_memunmap(new_memmap, data.size);
+#ifdef CONFIG_ARM64 + /* + * Efi fake mem support for arm64 is introduced for debug propose + * only. However efi_memmap_init_late in arm_enable_runtime_services + * will free this memory which will lead to UAF on efi.memmap.map. + * + * In order to slove this, clear efi.memmap.flags to skip free. + * Since efi map is never freed in arm64, this will not lead to + * memroy leak. + */ + data.flags &= ~(EFI_MEMMAP_SLAB | EFI_MEMMAP_MEMBLOCK); +#endif + efi_memmap_install(&data); }