Jump to content

Kernel page-table isolation

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by ThurnerRupert (talk | contribs) at 06:22, 6 January 2018. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Kernel page-table isolation (KPTI, previously called KAISER)[1][2] is a Linux kernel feature that mitigates the Meltdown security vulnerability (affecting mainly Intel's x86 CPUs)[3] and improves kernel hardening against attempts to bypass kernel address space layout randomization (KASLR). It works by better isolating user space and kernel space memory.[4][5] KPTI was merged into Linux kernel version 4.15,[6] to be released in early 2018, and backported to Linux kernels 4.14.11, 4.9.75.[7][8] Windows[9] and macOS[10] released similar updates. KPTI does not address the related Spectre vulnerability.[11]

Background on KAISER

The KPTI patches were based on KAISER (short for Kernel Address Isolation to have Side-channels Efficiently Removed)[5], published in June 2017 back when Meltdown was not known yet. KAISER improves on KASLR, a 2014 mitigation for a much less severe issue. Whereas KASLR merely prevents address mappings from leaking, KAISER also prevents the data from leaking, thereby covering the Meltdown case.[12]

In 2014, the Linux kernel adopted kernel address space layout randomization (KASLR),[13] which makes it more difficult to exploit other kernel vulnerabilities,[14] which relies on kernel address mappings remaining hidden from user space.[15] Despite prohibiting access to these kernel mappings, it turns out that there are several side-channel attacks in modern processors that can leak the location of this memory, making it possible to work around KASLR.[5][16][17][18]

In 2017, KAISER addressed these problems in KASLR by eliminating the source of the address leakage.[19] KPTI is based on KAISER. Without KPTI enabled, whenever executing user-space code (applications), Linux would also keep its entire kernel memory mapped in page tables, although protected from access. The advantage is that when the application makes a system call into the kernel or an interrupt is received, kernel page tables are always present, so most context switching-related overheads (TLB flush, page-table swapping, etc) can be avoided.[4]

Meltdown vulnerability and KPTI

In January 2018, the Meltdown vulnerability was published, known to affect Intel's x86 CPUs and ARM Cortex A75.[20][21] It was a far more severe vulnerability than the KASLR bypass that KAISER originally intended to fix: It was found that contents of kernel memory could also be leaked, not just the locations of memory mappings, as previously thought. The KAISER patches were re-purposed to fix Meltdown (and renamed to KPTI in the process).

KPTI (based on KAISER) prevents Meltdown by preventing all protected locations from being mapped to user space.

AMD x86 processors are not currently known to be affected by Meltdown and don't need KPTI to mitigate them.[11][22] However, AMD processors are still susceptible to KASLR bypass when KPTI is disabled.[18]

Implementation

KPTI fixes these leaks by separating user-space and kernel-space page tables entirely. On processors that support the process-context identifiers (PCID), a TLB flush can be avoided,[4] but even then it comes at a significant performance cost, particularly in syscall-heavy and interrupt-heavy workloads.[23]

The overhead was measured to be 0.28% according to KAISER's original authors;[5] a Linux developer measured it to be roughly 5% for most workloads and up to 30% in some cases, even with the PCID optimization;[4] for database engine PostgreSQL the impact on read-only tests on an Intel Skylake processor was 7–17% (or 16–23% without PCID),[24] while a full benchmark lost 13–19% (Coffee Lake vs. Broadwell-E).[25] Many benchmarks have been done by Phoronix,[26][27][28] Redis slowed by 6–7%.[25] Linux kernel compilation slowed down by 5% on Haswell.[29]

KPTI can partially be disabled with the "nopti" kernel boot option. Also provisions were created to disable KPTI if newer processors fix the information leaks.[1]

References

  1. ^ a b Corbet, Jonathan (20 December 2017). "The current state of kernel page-table isolation". LWN.net. {{cite news}}: Cite has empty unknown parameter: |dead-url= (help)
  2. ^ Cimpanu, Catalin (3 January 2018). "OS Makers Preparing Patches for Secret Intel CPU Security Bug". Bleeping Computer.
  3. ^ "Spectre, Meltdown: Critical CPU Security Flaws Explained - ExtremeTech". ExtremeTech. 2018-01-04. Retrieved 2018-01-05.
  4. ^ a b c d Corbet, Jonathan (15 November 2017). "KAISER: hiding the kernel from user space". LWN.net.
  5. ^ a b c d Gruss, Daniel; Lipp, Moritz; Schwarz, Michael; Fellner, Richard; Maurice, Clémentine; Mangard, Stefan (24 June 2017). KASLR is Dead: Long Live KASLR (PDF). Engineering Secure Software and Systems 2017.
  6. ^ Corbet, Jonathan (20 December 2017). "Kernel page-table isolation merged". LWN.net.
  7. ^ Kroah-Hartman, Greg (2018-01-02). "Linux 4.14.11 Changelog". kernel.org. {{cite web}}: Cite has empty unknown parameter: |dead-url= (help)
  8. ^ Kroah-Hartman, Greg (2018-01-05). "Linux 4.9.75 Changelog". kernel.org. {{cite web}}: Cite has empty unknown parameter: |dead-url= (help)
  9. ^ Alex Ionescu [@aionescu] (14 November 2017). "Windows 17035 Kernel ASLR/VA Isolation In Practice" (Tweet) – via Twitter.
  10. ^ "Apple has already partially implemented fix in macOS for 'KPTI' Intel CPU security flaw". AppleInsider. Retrieved 2018-01-03.
  11. ^ a b Coldewey, Devin (4 January 2018). "Kernel panic! What are Meltdown and Spectre, the bugs affecting nearly every computer and device?". TechCrunch.
  12. ^ "Meltdown" (PDF).
  13. ^ "Linux kernel 3.14, Section 1.7. Kernel address space randomization". kernelnewbies.org. 30 March 2014. Retrieved 2 April 2014.
  14. ^ Bhattacharjee, Abhishek; Lustig, Daniel (29 September 2017). Architectural and Operating System Support for Virtual Memory. Morgan & Claypool Publishers. p. 56. ISBN 9781627059336.
  15. ^ Kerner, Sean Michael (3 January 2018). "KPTI Intel Chip Flaw Exposes Security Risks". eWEEK.
  16. ^ Jang, Yeongjin; Lee, Sangho; Kim, Taesoo (2016). "Breaking Kernel Address Space Layout Randomization with Intel TSX" (PDF). 2016 ACM SIGSAC Conference on Computer and Communications Security. CCS '16. New York, NY, USA: ACM: 380–392. doi:10.1145/2976749.2978321. ISBN 9781450341394.
  17. ^ Gruss, Daniel; Maurice, Clémentine; Fogh, Anders; Lipp, Moritz; Mangard, Stefan (2016). "Prefetch Side-Channel Attacks: Bypassing SMAP and Kernel ASLR" (PDF). 2016 ACM SIGSAC Conference on Computer and Communications Security. CCS '16. New York, NY, USA: ACM: 368–379. doi:10.1145/2976749.2978356. ISBN 9781450341394.
  18. ^ a b Hund, R.; Willems, C.; Holz, T. (May 2013). "Practical Timing Side Channel Attacks against Kernel Space ASLR" (PDF). 2013 IEEE Symposium on Security and Privacy: 191–205. doi:10.1109/sp.2013.23.
  19. ^ "KASLR is Dead: Long Live KASLR" (PDF).
  20. ^ "Spectre, Meltdown: Critical CPU Security Flaws Explained - ExtremeTech". ExtremeTech. 2018-01-04. Retrieved 2018-01-05.
  21. ^ Coldewey, Devin (4 January 2018). "Kernel panic! What are Meltdown and Spectre, the bugs affecting nearly every computer and device?". TechCrunch.
  22. ^ "An Update on AMD Processor Security". AMD. 4 January 2018.
  23. ^ Leyden, John; Williams, Chris (2 January 2018). "Kernel-memory-leaking Intel processor design flaw forces Linux, Windows redesign". The Register.
  24. ^ Freund, Andres (2018-01-02). "heads up: Fix for intel hardware bug will lead to performance regressions". PostgreSQL development mailing list (pgsql-hackers).
  25. ^ a b Larabel, Michael (2018-01-02). "Initial Benchmarks Of The Performance Impact Resulting From Linux's x86 Security Changes". Phoronix.
  26. ^ Larabel, Michael (2 January 2018). "Linux Gaming Performance Doesn't Appear Affected By The x86 PTI Work". Phoronix.
  27. ^ Larabel, Michael (3 January 2018). "VM Performance Showing Mixed Impact With Linux 4.15 KPTI Patches - Phoronix". Phoronix.
  28. ^ Larabel, Michael (3 January 2018). "Further Analyzing The Intel CPU "x86 PTI Issue" On More Systems". Phoronix.
  29. ^ Velvindron, Loganaden (2018-01-04). "Linux KPTI performance hit on real workloads". Loganaden Velvindron. Retrieved 2018-01-05.