]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
PTI: unbreak EFI old_memmap
authorJiri Kosina <jkosina@suse.cz>
Fri, 5 Jan 2018 19:21:38 +0000 (11:21 -0800)
committerKirtikar Kashyap <kirtikar.kashyap@oracle.com>
Fri, 12 Jan 2018 18:20:11 +0000 (10:20 -0800)
old_memmap's efi_call_phys_prolog() calls set_pgd() with swapper PGD that
has PAGE_USER set, which makes PTI set NX on it, and therefore EFI can't
execute it's code.

Fix that by forcefully clearing _PAGE_NX from the PGD (this can't be done
by the pgprot API).

_PAGE_NX will be automatically reintroduced in efi_call_phys_epilog(), as
_set_pgd() will again notice that this is _PAGE_USER, and set _PAGE_NX on
it.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Orabug: 27333760
CVE: CVE-2017-5754
Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Signed-off-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
arch/x86/platform/efi/efi_64.c

index a0ac0f9c307f661c8b3ed08c4ca6d23507772e36..3327c3155a9f44e6a71df02906c1ce45ac0ff5d3 100644 (file)
@@ -95,6 +95,12 @@ pgd_t * __init efi_call_phys_prolog(void)
                save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
                vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
                set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
+               /*
+                * pgprot API doesn't clear it for PGD
+                *
+                * Will be brought back automatically in _epilog()
+                */
+               pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX;
        }
        __flush_tlb_all();