Skip to content

Commit 3cc0286

Browse files
ardbiesheuvelIngo Molnar
authored andcommitted
efi/x86: avoid KASAN false positives when accessing the 1: 1 mapping
When installing the EFI virtual address map during early boot, we access the EFI system table to retrieve the 1:1 mapped address of the SetVirtualAddressMap() EFI runtime service. This memory is not known to KASAN, so on KASAN enabled builds, this may result in a splat like ================================================================== BUG: KASAN: user-memory-access in efi_set_virtual_address_map+0x141/0x354 Read of size 4 at addr 000000003fbeef38 by task swapper/0/0 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.5.0-rc5+ torvalds#758 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 Call Trace: dump_stack+0x8b/0xbb ? efi_set_virtual_address_map+0x141/0x354 ? efi_set_virtual_address_map+0x141/0x354 __kasan_report+0x176/0x192 ? efi_set_virtual_address_map+0x141/0x354 kasan_report+0xe/0x20 efi_set_virtual_address_map+0x141/0x354 ? efi_thunk_runtime_setup+0x148/0x148 ? __inc_numa_state+0x19/0x90 ? memcpy+0x34/0x50 efi_enter_virtual_mode+0x5fd/0x67d start_kernel+0x5cd/0x682 ? mem_encrypt_init+0x6/0x6 ? x86_family+0x5/0x20 ? load_ucode_bsp+0x46/0x154 secondary_startup_64+0xa4/0xb0 ================================================================== Since this code runs only a single time during early boot, let's annotate it as __no_sanitize_address so KASAN disregards it entirely. Fixes: 6982947 ("efi/x86: Split SetVirtualAddresMap() wrappers into ...") Reported-by: Qian Cai <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 484a418 commit 3cc0286

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

arch/x86/platform/efi/efi_64.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ static DEFINE_SPINLOCK(efi_runtime_lock);
543543
__s; \
544544
})
545545

546-
static efi_status_t __init
546+
static efi_status_t __init __no_sanitize_address
547547
efi_thunk_set_virtual_address_map(unsigned long memory_map_size,
548548
unsigned long descriptor_size,
549549
u32 descriptor_version,
@@ -882,10 +882,11 @@ void __init efi_thunk_runtime_setup(void)
882882
efi.query_capsule_caps = efi_thunk_query_capsule_caps;
883883
}
884884

885-
efi_status_t __init efi_set_virtual_address_map(unsigned long memory_map_size,
886-
unsigned long descriptor_size,
887-
u32 descriptor_version,
888-
efi_memory_desc_t *virtual_map)
885+
efi_status_t __init __no_sanitize_address
886+
efi_set_virtual_address_map(unsigned long memory_map_size,
887+
unsigned long descriptor_size,
888+
u32 descriptor_version,
889+
efi_memory_desc_t *virtual_map)
889890
{
890891
efi_status_t status;
891892
unsigned long flags;

0 commit comments

Comments
 (0)