{"id":11244,"date":"2018-01-25T20:41:13","date_gmt":"2018-01-26T04:41:13","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2018\/01\/25\/news-5015\/"},"modified":"2018-01-25T20:41:13","modified_gmt":"2018-01-26T04:41:13","slug":"news-5015","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2018\/01\/25\/news-5015\/","title":{"rendered":"A Deep Dive Analysis of Microsoft\u2019s Kernel Virtual Address Shadow Feature"},"content":{"rendered":"<p><strong>Credit to Author: Minh Tran| Date: Thu, 25 Jan 2018 19:05:59 +0000<\/strong><\/p>\n<div class=\"entry\">\n<p>&nbsp;<\/p>\n<div>\n<p style=\"text-align: center;\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/meltdown0.png\" style=\"width: 296px; height: 500px;\" \/><\/p>\n<\/p><\/div>\n<h1>Introduction<\/h1>\n<p>The story involving <a href=\"https:\/\/meltdownattack.com\/\">Meltdown<\/a> and <a href=\"https:\/\/spectreattack.com\/\">Spectre<\/a> continues as vendors (including major players like <a href=\"https:\/\/support.apple.com\/en-us\/HT208394\">Apple<\/a> <a href=\"http:\/\/www.zdnet.com\/article\/meltdown-spectre-oracles-critical-patch-update-offers-fixes-against-cpu-attacks\/\">Oracle<\/a>, and <a href=\"https:\/\/www.pcworld.com\/article\/3246189\/security\/microsoft-halts-meltdown-patches-windows-amd-pcs-unbootable.html\">Microsoft<\/a>, among others ) scramble to issue patches for their products. Even <a href=\"https:\/\/www.reuters.com\/article\/us-cyber-intel\/intel-problem-in-patches-for-spectre-meltdown-extends-to-newer-chips-idUSKBN1F7087\">Intel&rsquo;s own patches<\/a> have hidden problems that have led to higher-than-expected reboot rates, and these problems extend all the way from Sandy Bridge (2011) to Kaby Lake (2016).<\/p>\n<p>In a previous <a href=\"https:\/\/blog.fortinet.com\/2018\/01\/17\/into-the-implementation-of-spectre\">blog post<\/a>, FortiGuard Labs detailed the implementation of Spectre, and in another we provided a <a href=\"https:\/\/blog.fortinet.com\/2018\/01\/12\/dr-strangepatch-or-how-i-learned-to-stop-worrying-about-meltdown-and-spectre-and-love-security-advisory-adv180002\">technical analysis<\/a> of Microsoft&lsquo;s patches (<a href=\"https:\/\/portal.msrc.microsoft.com\/en-US\/security-guidance\/advisory\/ADV180002\">Microsoft Security Advisory ADV180002<\/a>). One of the key features of Microsoft&lsquo;s patches is the &ldquo;Kernel Virtual Address Shadow&rdquo; (a term coined by Microsoft), or KVAS for short. This feature effectively blocks the Meltdown attack, as it leaves very little kernel memory accessible to user mode code. In this blog post we provide a deep dive analysis of this feature.<\/p>\n<h1>Overall Design<\/h1>\n<p>Before digging into the details, it&rsquo;s worthwhile to understand the overall context. The following table summarizes the Spectre and Meltdown attacks:<\/p>\n<p>&nbsp;<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/meltdown1.png\" style=\"width: 975px; height: 372px;\" \/><\/p>\n<p align=\"center\">Figure 1 Executive Summary (credits go to <a href=\"https:\/\/www.kb.cert.org\/vuls\/id\/584653\">CERT<\/a>)<\/p>\n<p>As we can see, the difficulty of mounting a Meltdown attack is low (i.e. low cost) hence the chance of it being exploited in the real world scenarios will be high, as evidenced by the AV-Test research team&rsquo;s discovery of 119 new malicious samples in just the two weeks following the disclosure of the vulnerability. As a result, it makes perfect sense for Microsoft to focus on defending against that attack first.<\/p>\n<p>Before delving into the details, we wrote this piece assuming that readers already possess a strong knowledge of low level system concepts and mechanisms such as virtual memory, 32-bit (aka x86) vs 64-bit (aka x64), MSR, kernel-mode vs user-mode, and so on. For details about those concepts and mechanisms, the Intel&reg; 64 and IA-32 Architectures Software Developer&#39;s Manuals are the authoritative resources. Providing a primer on those concepts is beyond the scope of this paper, and we recommend that those unfamiliar with these details to start there.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown2.png\" style=\"width: 633px; height: 585px;\" \/><\/p>\n<p align=\"center\">Figure 2 The Overall Design<\/p>\n<p>Figure 2 depicts the overall idea behind KVAS. Conceptually speaking, the system is partitioned into three parts: the entries, arbitrary control flow in the middle, and the exits. The key insight here is that the kernel space and the user space are separated thanks to clever paging structures. Only a minimal numbers of pages are mapped in both the user space and the kernel space. As a result, even if a Meltdown attack were to be successful, it still could not leak kernel memory. That&rsquo;s because the entries and the exits swap address spaces back and forth such that only the kernel code can access kernel memory space. An extra benefit of this design is that it achieves its goal simply by manipulating the paging structures without having to rely on any extra support at the hardware level (e.g. microcode updates)<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown3.png\" style=\"width: 975px; height: 439px;\" \/><\/p>\n<p align=\"center\">Figure 3 NtOpenProcess Is Not Accessible<\/p>\n<p>As can be seen in figure 3, the code region of <strong>NtOpenProcess<\/strong> is not accessible because it is not mapped using <strong>UserDirectoryTableBase<\/strong>.<\/p>\n<h1>Analysis of The Implementation<\/h1>\n<p>This section highlights key findings of our analysis of the Kernel VA Shadow Feature (KVAS). Here are the key details of the NT Kernel itself:<\/p>\n<p>Windows 7 x64: 6.1.7601.24000<\/p>\n<p>Size: 5581544 bytes<\/p>\n<p>Sha256: 9A6C19B29EBB8D9399C771F2B570E6DCDDF75AC7F2A5F4E8013F4EC7A31F7CA8<\/p>\n<p>We found that KVAS is initialized very early in the boot process. Specifically, KVAS is enabled in the OS initialization itself. The entry point of the NT Kernel is called <strong>KiSystemStartup, <\/strong>and is invoked by the OS loader. <strong>KiSystemStartup <\/strong>in turn performs basic initialization of several things, one of which is the calling of <strong>KiInitializeBootStructures<\/strong><strong>.<\/strong><\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown4.png\" style=\"width: 519px; height: 103px;\" \/><\/p>\n<p align=\"center\">Figure 4 KiInitializeBootStructures<\/p>\n<p><strong>KiInitializeBootStructures<\/strong> in turn calls <strong>KiEnableKvaShadowing<\/strong>, which is responsible for enabling KVAS and sets <strong>KiKvaShadow<\/strong> = 1.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown5.png\" style=\"width: 627px; height: 265px;\" \/><\/p>\n<p align=\"center\">Figure 5 KiEnableKvaShadowing<\/p>\n<p>We also observed that based on process-context identifiers (PCID &#8211; which is a performance optimization feature to avoid flushing the entire translation lookaside buffer), the global flag <strong>KiKvaShadowMode<\/strong> will be set accordingly to either 1 (<strong>KiFlushPcid<\/strong> != 0) or 2 (<strong>KiFlushPcid<\/strong> == 0).<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown6.png\" style=\"width: 567px; height: 345px;\" \/><\/p>\n<p align=\"center\">Figure 6 KiKvaShadow and PCID<\/p>\n<p>The key part of the whole process is the setting up of the system call handlers themselves.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown7.png\" style=\"width: 601px; height: 223px;\" \/><\/p>\n<p align=\"center\">Figure 7 Setting Up of the System Call Handlers<\/p>\n<p>But first, a quick primer about the mechanism used to perform system calls. When the SYSCALL instructions are executed (e.g. in <strong>ntdll.dll<\/strong>), the code execution is switched to a kernel-mode routine whose address is pointed to by a Model Specific Register (MSR). MSRs are special registers that must be accessed through <strong>rdmsr<\/strong> and <strong>wrmsr<\/strong> CPU instructions using indices. For example, the index for <strong>IA32_STAR<\/strong> is C0000081 and <strong>IA32_LSTAR<\/strong> is C0000082 and so on.<\/p>\n<ul>\n<li><strong>IA32_STAR<\/strong> (0xC0000081) &#8211; Ring 0 and Ring 3 Segment bases, as well as SYSCALL EIP. Lower 32 bits = SYSCALL EIP, bits 32-47 are the kernel segment base, and bits 48-63 are the user segment base.<\/li>\n<li><strong>IA32_CSTAR<\/strong> (0xC0000083) &#8211; The kernel&#39;s RIP for SYSCALL in compatibility mode.<\/li>\n<li><strong>IA32_LSTAR<\/strong> (0xC0000082) &#8211; The kernel&#39;s RIP for SYSCALL in long mode (64-bit software)<\/li>\n<\/ul>\n<p>Basically, this all results in the global flag <strong>KiKvaShadow<\/strong> being checked. If the flag check for <strong>KiKvaShadow<\/strong> is TRUE, the normal system call handlers (<strong>KiSystemCall32<\/strong> and <strong>KiSystemCall64<\/strong>) will not be used, and the shadow versions will be used instead. &nbsp;Further, if the processor is from AMD then the AMD variant will be used.<\/p>\n<p>When the SYSCALL instructions are executed, control is then transferred to the system call handlers immediately, which means those handlers have to be mapped in <strong>UserDirectoryTableBase<\/strong> as well.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown8.png\" style=\"width: 623px; height: 275px;\" \/><\/p>\n<p align=\"center\">Figure 8 KiSystemCall64Shadow is Mapped<\/p>\n<p>Similarly, interrupt service routines (ISRs) also have shadow versions:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown9.png\" style=\"width: 507px; height: 168px;\" \/><\/p>\n<p align=\"center\">Figure 9 ISR is Shadowed<\/p>\n<p>And these ISRs also have to be readily accessible.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown10.png\" style=\"width: 619px; height: 276px;\" \/><\/p>\n<p align=\"center\">Figure 10 KiNmiInterruptShadow<\/p>\n<h1>Prime Example &ndash; System Calls<\/h1>\n<p>To illustrate how the address spaces get swapped back and forth, we will focus on one prime example: system calls. As before, we will intentionally gloss over the details.&nbsp; Any background information or details, if needed, can be found in Intel&rsquo;s System Programming Guide (Volume 3).<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/Meltdown11.png\" style=\"width: 617px; height: 186px;\" \/><\/p>\n<p align=\"center\">Figure 11 KiSystemCall64Shadow<\/p>\n<p>First, SWAPGS is used to exchange the current GS base register value with the value contained in MSR address C0000102H (<strong>IA32_KERNEL_GS_BASE<\/strong>). Initially, very little kernel memory is mapped (i.e. secure) so all important information has to be obtained through the GS segment. GS:6000h in turn contains the physical address of the base of PML4 (i.e. page directory for x64).<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/iot%20botnet\/mini%20table.png\" style=\"width: 220px; height: 88px;\" \/><\/p>\n<p align=\"center\">Figure 12 Key Parameters in GS Segment<\/p>\n<p>A flag (gs:6018h) will be checked, and if swapping is needed then the base of PML4 (corresponding to the kernel address space) will be moved into CR3. At this point the kernel stack is finally accessible and everything works normally. We note that swapping may not always be needed as it may have already happened previously (for example, interrupt while servicing system calls).<\/p>\n<p>One subtle thing to notice is that after the new PML4 has been moved into CR3 the address space is switched instantaneously, and the very next instruction fetch happens on the new address space (private to the kernel). But since <strong>KiSystemCall64Shadow<\/strong> is mapped into the very same virtual address, everything &ldquo;just works&rdquo;.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/Meltdown13.png\" style=\"width: 617px; height: 158px;\" \/><\/p>\n<p align=\"center\">Figure 13 KiSystemCall64AmdShadow<\/p>\n<p>As can be seen here, the differences between the Intel version and the AMD version of the system call handler is quite minimal: both end up calling KiSystemCall64ShadowCommon, which in turn routes system calls as usual using <strong>KeServiceDescriptorTable<\/strong> (a.k.a. the System Service Descriptor\/Dispatch Table &#8211; <strong>SSDT<\/strong> for short) or <strong>KeServiceDescriptorTableShadow<\/strong> (contains routine addresses in <strong>win32k.sys<\/strong>)<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/Meltdown14.png\" style=\"width: 604px; height: 299px;\" \/><\/p>\n<p align=\"center\">Figure 14 Return From System Calls<\/p>\n<p>The address space gets secured before returning back to user mode through the <strong>sysret<\/strong> instruction.<\/p>\n<h1>Security Analysis<\/h1>\n<p>We applied the same analysis to the entries and exits of the kernel. Take, for example, the case of Interrupt Service Routines (ISRs).<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/Meltdown15.png\" style=\"width: 612px; height: 333px;\" \/><\/p>\n<p align=\"center\">Figure 15 Interrupt Service Routines<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/Meltdown16.png\" \/><\/p>\n<p align=\"center\">Figure 16 Exit From the Kernel<\/p>\n<p>&nbsp;<\/p>\n<p>We can see that the same design is applied to ISRs. Thanks to this clever design, it is a rather straightforward process to deduce its security strategy.&nbsp; Since only the entries and the exits (and a small amount of supporting data) is mapped it is clear, the kernel is therefore hardened against kernel attacks like Meltdown.<\/p>\n<p>Certainly, there is no such thing as a free lunch. Previously, when an application made a system call into the kernel or an interrupt was received, the kernel page tables were always present, so most context switching-related overheads (TLB flushing, page-table swapping, etc.) of KVAS were nonexistent. With KVAS, however, we can also expect that in syscall-heavy and interrupt-heavy workloads (e.g. heavy IOs like NVM Express SSD) that there will be degradation in performance. This could be severe in cloud services, such as what already happened with&nbsp; <a href=\"https:\/\/www.epicgames.com\/fortnite\/forums\/news\/announcements\/132642-epic-services-stability-update\">EpicGames<\/a>:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/Meltdown17.png\" style=\"width: 974px; height: 460px;\" \/><\/p>\n<h1>Final Thoughts<\/h1>\n<p>Overall, Kernel Virtual Address Shadow is an elegant feature. It gets the job done with what we consider to be a reasonable performance trade-off.<\/p>\n<p>As always, FortiGuard Labs will keep monitoring the threat landscape and keep everybody updated with insightful research.<\/p>\n<p>-= FortiGuard Lion Team =-<\/p>\n<p>&nbsp;<\/p>\n<p><em>Sign up for our weekly FortiGuard&nbsp;<\/em><a href=\"https:\/\/fortiguard.com\/resources\/threat-brief\"><em>intel briefs<\/em><\/a>&nbsp;<em>or<\/em>&nbsp;<em>to be a part of our&nbsp;<\/em><a href=\"https:\/\/tis.fortiguard.com\/signup\/\"><em>open beta<\/em><\/a><em>&nbsp;of Fortinet&rsquo;s FortiGuard Threat Intelligence Service.<\/em><\/p>\n<\/div<br \/><a href=\"https:\/\/blog.fortinet.com\/2018\/01\/25\/a-deep-dive-analysis-of-microsoft-s-kernel-virtual-address-shadow-feature\" target=\"bwo\" >https:\/\/blog.fortinet.com\/feed<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/images\/Images\/images%202\/images%203\/images%204\/images%205\/images%206\/images%208\/Hex%20blog\/more%20hex\/baidu\/more%20baidu\/cerber\/Mamba\/shamoon\/More%20images\/Google\/Google2\/Google3\/More%20Google\/Evasive01\/evasive3\/Ichitaro\/Demand%20Banners\/Partner%20blog\/blog%20blog\/Blog%20blog%20blog\/Blog%20blog%20blog%20blog\/Demand%20Banners\/PowerDNS\/power%20dns%202\/verticals%20blogs\/blogs%20Jan%2012\/Meltdown%20Spectre%203\/Meltdown%20Spectre%204\/meltdown0.png\"\/><\/p>\n<p><strong>Credit to Author: Minh Tran| Date: Thu, 25 Jan 2018 19:05:59 +0000<\/strong><\/p>\n<p>One of the key features of Microsoft\u2018s patches is the \u201cKernel Virtual Address Shadow\u201d (a term coined by Microsoft), or KVAS for short. This feature effectively blocks the Meltdown attack, as it leaves very little kernel memory accessible to user mode code. In this blog post we provide a deep dive analysis of this feature.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10424,10378],"tags":[],"class_list":["post-11244","post","type-post","status-publish","format-standard","hentry","category-fortinet","category-security"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/11244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=11244"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/11244\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=11244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=11244"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=11244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}