Kernel page-table isolation
Kernel page-table isolation (KPTI or PTI,[1] previously called KAISER)[2][3] is a Linux kernel feature that mitigates the Meltdown security vulnerability (affecting mainly Intel's x86 CPUs)[4] 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.[5][6] KPTI was merged into Linux kernel version 4.15,[7] and backported to Linux kernels 4.14.11, 4.9.75, and 4.4.110.[8][9][10] Windows[11] and macOS[12] released similar updates. KPTI does not address the related Spectre vulnerability.[13]
Background on KAISER
The KPTI patches were based on KAISER (short for Kernel Address Isolation to have Side-channels Efficiently Removed),[6] a technique conceived in 2016[14] and published in June 2017 back when Meltdown was not known yet. KAISER makes it harder to defeat KASLR, a 2014 mitigation for a much less severe issue.
In 2014, the Linux kernel adopted kernel address space layout randomization (KASLR),[15] which makes it more difficult to exploit other kernel vulnerabilities,[16] which relies on kernel address mappings remaining hidden from user space.[17] 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.[6][18][19][20]
KAISER addressed these problems in KASLR by eliminating some sources of address leakage.[6] Whereas KASLR merely prevents address mappings from leaking, KAISER also prevents the data from leaking, thereby covering the Meltdown case.[21]
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.[5]
Meltdown vulnerability and KPTI
In January 2018, the Meltdown vulnerability was published, known to affect Intel's x86 CPUs and ARM Cortex-A75.[22][23] 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.
KPTI (conceptually based on KAISER) prevents Meltdown by preventing most 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.[13][24] However, AMD processors are still susceptible to KASLR bypass when KPTI is disabled.[20]
Implementation
KPTI fixes these leaks by separating user-space and kernel-space page tables entirely. One set of page tables includes both kernel-space and user-space addresses same as before, but it is only used when the system is running in kernel mode. The second set of page tables for use in user mode contains a copy of user-space and a minimal set of kernel-space mappings that provides the information needed to enter or exit system calls, interrupts and exceptions.[5]
On processors that support the process-context identifiers (PCID), a translation lookaside buffer (TLB) flush can be avoided,[5] but even then it comes at a significant performance cost, particularly in syscall-heavy and interrupt-heavy workloads.[25]
The overhead was measured to be 0.28% according to KAISER's original authors;[6] a Linux developer measured it to be roughly 5% for most workloads and up to 30% in some cases, even with the PCID optimization;[5] for database engine PostgreSQL the impact on read-only tests on an Intel Skylake processor was 7–17% (or 16–23% without PCID),[26] while a full benchmark lost 13–19% (Coffee Lake vs. Broadwell-E).[27] Many benchmarks have been done by Phoronix,[28][29][1] Redis slowed by 6–7%.[27] Linux kernel compilation slowed down by 5% on Haswell.[30]
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.[2]
References
- ↑ 1.0 1.1 "Further Analyzing The Intel CPU "x86 PTI Issue" On More Systems" (in en). 2018-01-03. https://www.phoronix.com/scan.php?page=article&item=linux-more-x86pti.
- ↑ 2.0 2.1 "The current state of kernel page-table isolation". LWN.net. 2017-12-20. https://lwn.net/Articles/741878/.
- ↑ "OS Makers Preparing Patches for Secret Intel CPU Security Bug" (in en-us). Bleeping Computer. 2018-01-03. https://www.bleepingcomputer.com/news/security/os-makers-preparing-patches-for-secret-intel-cpu-security-bug/.
- ↑ "Spectre, Meltdown: Critical CPU Security Flaws Explained – ExtremeTech" (in en-US). ExtremeTech. 2018-01-04. https://www.extremetech.com/computing/261439-spectre-meltdown-new-critical-security-flaws-explored-explained.
- ↑ 5.0 5.1 5.2 5.3 5.4 "KAISER: hiding the kernel from user space". LWN.net. 2017-11-15. https://lwn.net/Articles/738975/.
- ↑ 6.0 6.1 6.2 6.3 6.4 "KASLR is Dead: Long Live KASLR". Engineering Secure Software and Systems 2017. 2017-06-24. https://gruss.cc/files/kaiser.pdf.
- ↑ "Kernel page-table isolation merged". LWN.net. 2017-12-20. https://lwn.net/Articles/742404/.
- ↑ "Linux 4.14.11 Changelog". 2018-01-02. https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.14.11.
- ↑ "Linux 4.9.75 Changelog". 2018-01-05. https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.9.75.
- ↑ "Linux 4.4.110 Changelog". 2018-01-05. https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.4.110.
- ↑ @aionescu (2017-11-14). "Windows 17035 Kernel ASLR/VA Isolation In Practice". https://twitter.com/aionescu/status/930412525111296000.
- ↑ "Apple has already partially implemented fix in macOS for 'KPTI' Intel CPU security flaw" (in en-US). 3 January 2018. http://appleinsider.com/articles/18/01/03/apple-has-already-partially-implemented-fix-in-macos-for-kpti-intel-cpu-security-flaw.
- ↑ 13.0 13.1 "Kernel panic! What are Meltdown and Spectre, the bugs affecting nearly every computer and device?" (in en). TechCrunch. 2018-01-04. https://techcrunch.com/2018/01/03/kernel-panic-what-are-meltdown-and-spectre-the-bugs-affecting-nearly-every-computer-and-device/.
- ↑ "#FunFact: We submitted #KAISER to #bhusa17 and got it rejected". 2018-01-03. https://twitter.com/lavados/status/948536300830851072.
- ↑ "Linux kernel 3.14, Section 1.7. Kernel address space randomization". 2014-03-30. http://kernelnewbies.org/Linux_3.14#head-192cae48200fccde67b36c75cdb6c6d8214cccb3.
- ↑ (in en) Architectural and Operating System Support for Virtual Memory. Morgan & Claypool Publishers. 2017-09-29. pp. 56. ISBN 978-1-62705-933-6. https://books.google.com/books?id=roM4DwAAQBAJ&pg=PA56.
- ↑ "KPTI Intel Chip Flaw Exposes Security Risks" (in en-US). eWEEK. 2018-01-03. http://www.eweek.com/security/kpti-intel-chip-flaw-exposes-security-risks.
- ↑ "Breaking Kernel Address Space Layout Randomization with Intel TSX". Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. CCS '16. New York, NY, USA: ACM. 2016. pp. 380–392. doi:10.1145/2976749.2978321. ISBN 978-1-4503-4139-4. http://people.oregonstate.edu/~jangye/assets/papers/2016/jang:drk-bh.pdf.
- ↑ "Prefetch Side-Channel Attacks". Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. CCS '16. New York, NY, USA: ACM. 2016. pp. 368–379. doi:10.1145/2976749.2978356. ISBN 978-1-4503-4139-4. https://gruss.cc/files/prefetch.pdf.
- ↑ 20.0 20.1 "Practical Timing Side Channel Attacks against Kernel Space ASLR". 2013 IEEE Symposium on Security and Privacy. May 2013. pp. 191–205. doi:10.1109/sp.2013.23. ISBN 978-0-7695-4977-4. https://www.ieee-security.org/TC/SP2013/papers/4977a191.pdf.
- ↑ "Meltdown". https://meltdownattack.com/meltdown.pdf.
- ↑ "Spectre, Meltdown: Critical CPU Security Flaws Explained – ExtremeTech" (in en-US). ExtremeTech. 2018-01-04. https://www.extremetech.com/computing/261439-spectre-meltdown-new-critical-security-flaws-explored-explained.
- ↑ "Kernel panic! What are Meltdown and Spectre, the bugs affecting nearly every computer and device?" (in en). TechCrunch. 2018-01-04. https://techcrunch.com/2018/01/03/kernel-panic-what-are-meltdown-and-spectre-the-bugs-affecting-nearly-every-computer-and-device/.
- ↑ "An Update on AMD Processor Security". AMD. 2018-01-04. https://www.amd.com/en/corporate/speculative-execution.
- ↑ "Kernel-memory-leaking Intel processor design flaw forces Linux, Windows redesign". The Register. 2018-01-02. https://www.theregister.co.uk/2018/01/02/intel_cpu_design_flaw/.
- ↑ "heads up: Fix for intel hardware bug will lead to performance regressions". PostgreSQL development mailing list (pgsql-hackers). 2018-01-02. https://www.postgresql.org/message-id/20180102222354.qikjmf7dvnjgbkxe%40alap3.anarazel.de.
- ↑ 27.0 27.1 "Initial Benchmarks Of The Performance Impact Resulting From Linux's x86 Security Changes". Phoronix. 2018-01-02. https://www.phoronix.com/scan.php?page=article&item=linux-415-x86pti&num=2.
- ↑ "Linux Gaming Performance Doesn't Appear Affected By The x86 PTI Work" (in en). 2018-01-02. https://www.phoronix.com/scan.php?page=news_item&px=x86-PTI-Initial-Gaming-Tests.
- ↑ "VM Performance Showing Mixed Impact With Linux 4.15 KPTI Patches – Phoronix" (in en). 2018-01-03. https://www.phoronix.com/scan.php?page=article&item=linux-kpti-kvm.
- ↑ "Linux KPTI performance hit on real workloads". 2018-01-04. https://medium.com/@loganaden/linux-kpti-performance-hit-on-real-workloads-8da185482df3.
External links
Original source: https://en.wikipedia.org/wiki/Kernel page-table isolation.
Read more |