]> Git Repo - linux.git/commitdiff
efi/x86: Don't map the entire kernel text RW for mixed mode
authorArd Biesheuvel <[email protected]>
Mon, 13 Jan 2020 17:22:37 +0000 (18:22 +0100)
committerIngo Molnar <[email protected]>
Mon, 20 Jan 2020 07:13:01 +0000 (08:13 +0100)
The mixed mode thunking routine requires a part of it to be
mapped 1:1, and for this reason, we currently map the entire
kernel .text read/write in the EFI page tables, which is bad.

In fact, the kernel_map_pages_in_pgd() invocation that installs
this mapping is entirely redundant, since all of DRAM is already
1:1 mapped read/write in the EFI page tables when we reach this
point, which means that .rodata is mapped read-write as well.

So let's remap both .text and .rodata read-only in the EFI
page tables.

Signed-off-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
arch/x86/platform/efi/efi_64.c

index c13fa2150976a9f42e842b95a102635c16c0da20..6ec58ff60b56a48302d5fecf34993cba9cab5a75 100644 (file)
@@ -391,11 +391,11 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 
        efi_scratch.phys_stack = page_to_phys(page + 1); /* stack grows down */
 
-       npages = (_etext - _text) >> PAGE_SHIFT;
+       npages = (__end_rodata_aligned - _text) >> PAGE_SHIFT;
        text = __pa(_text);
        pfn = text >> PAGE_SHIFT;
 
-       pf = _PAGE_RW | _PAGE_ENC;
+       pf = _PAGE_ENC;
        if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, pf)) {
                pr_err("Failed to map kernel text 1:1\n");
                return 1;
This page took 0.058013 seconds and 4 git commands to generate.