{"id":996,"date":"2017-02-27T22:31:42","date_gmt":"2017-02-28T06:31:42","guid":{"rendered":"https:\/\/outflux.net\/blog\/?p=996"},"modified":"2019-07-08T20:23:50","modified_gmt":"2019-07-09T03:23:50","slug":"security-things-in-linux-v4-10","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2017\/02\/27\/security-things-in-linux-v4-10\/","title":{"rendered":"security things in Linux v4.10"},"content":{"rendered":"<p>Previously: <a href=\"\/blog\/archives\/2016\/12\/12\/security-things-in-linux-v4-9\/\">v4.9<\/a>.<\/p>\n<p>Here&#8217;s a quick summary of some of the interesting security things in last week&#8217;s v4.10 release of the Linux kernel:<\/p>\n<p><strong>PAN emulation on arm64<\/strong><\/p>\n<p>Catalin Marinas introduced <a href=\"https:\/\/git.kernel.org\/linus\/ba42822af1c287f038aa550f3578c61c212a892e\"><code>ARM64_SW_TTBR0_PAN<\/code><\/a>, which is functionally the arm64 equivalent of arm&#8217;s <a href=\"https:\/\/outflux.net\/blog\/archives\/2016\/09\/26\/security-things-in-linux-v4-3\/\"><code>CONFIG_CPU_SW_DOMAIN_PAN<\/code><\/a>. While Privileged eXecute Never (PXN) has been available in ARM hardware for a while now, Privileged Access Never (PAN) will only be available in hardware once vendors start manufacturing ARMv8.1 or later CPUs. Right now, everything is still ARMv8.0, which left a bit of a gap in security flaw mitigations on ARM since <code>CONFIG_CPU_SW_DOMAIN_PAN<\/code> can only provide PAN coverage on ARMv7 systems, but nothing existed on ARMv8.0. This solves that problem and closes a common exploitation method for arm64 systems.<\/p>\n<p><strong>thread_info relocation on arm64<\/strong><\/p>\n<p>As <a href=\"\/blog\/archives\/2016\/12\/12\/security-things-in-linux-v4-9\/\">done earlier for x86<\/a>, Mark Rutland has <a href=\"https:\/\/git.kernel.org\/linus\/c02433dd6de32f042cf3ffe476746b1115b8c096\">moved <code>thread_info<\/code> off the kernel stack on arm64<\/a>. With <code>thread_info<\/code> no longer on the stack, it&#8217;s more difficult for attackers to find it, which makes it harder to subvert the very sensitive <code>addr_limit<\/code> field.<\/p>\n<p><strong>linked list hardening<\/strong><br \/>\nI added <code>CONFIG_BUG_ON_DATA_CORRUPTION<\/code> to <a href=\"https:\/\/git.kernel.org\/linus\/de54ebbe26bb371a6f1fbc0593372232f04e3107\">restore the original <code>CONFIG_DEBUG_LIST<\/code> behavior<\/a> that existed prior to v2.6.27 (9 years ago): if list metadata corruption is detected, the kernel refuses to perform the operation, rather than just <code>WARN<\/code>ing and continuing with the corrupted operation anyway. Since linked list corruption (usually via heap overflows) are a common method for attackers to gain a <a href=\"https:\/\/git.kernel.org\/linus\/6819d101dd739dd4e8cbe60a98c9ebb224ecc992\">write-what-where primitive<\/a>, it&#8217;s important to stop the list add\/del operation if the metadata is obviously corrupted.<\/p>\n<p><strong>seeding kernel RNG from UEFI<\/strong><\/p>\n<p>A problem for many architectures is finding a viable source of early boot entropy to initialize the kernel Random Number Generator. For x86, this is mainly solved with the <code>RDRAND<\/code> instruction. On ARM, however, the solutions continue to be very vendor-specific. As it turns out, UEFI is supposed to hide various vendor-specific things behind a common set of APIs. The <code>EFI_RNG_PROTOCOL<\/code> call is designed to provide entropy, but it can&#8217;t be called when the kernel is running. To get entropy into the kernel, Ard Biesheuvel created a UEFI config table (<code>LINUX_EFI_RANDOM_SEED_TABLE_GUID<\/code>) that is  <a href=\"https:\/\/git.kernel.org\/linus\/568bc4e87033d232c5fd00d5b0cd22a2ccc04944\">populated<\/a> during the UEFI boot stub and <a href=\"https:\/\/git.kernel.org\/linus\/636259880a7e7d3446a707dddebc799da94bdd0b\">fed into the kernel entropy pool<\/a> during early boot.<\/p>\n<p><strong>arm64 W^X detection<\/strong><\/p>\n<p>As <a href=\"\/blog\/archives\/2016\/09\/27\/security-things-in-linux-v4-4\/\">done earlier for x86<\/a>, Laura Abbott implemented <a href=\"https:\/\/git.kernel.org\/linus\/1404d6f13e47c42f155e3c6a611b1bf4dd35dde9\">CONFIG_DEBUG_WX on arm64<\/a>. Now any dangerous arm64 kernel memory protections will be loudly reported at boot time.<\/p>\n<p><strong>64-bit <code>get_user()<\/code> zeroing fix on arm<\/strong><br \/>\nWhile the <a href=\"https:\/\/git.kernel.org\/linus\/9e3440481845b2ec22508f60837ee2cab2b6054f\">fix itself is pretty minor<\/a>, I like that this bug was found through a combined improvement to the usercopy test code in <code>lib\/test_user_copy.c<\/code>. Hoeun Ryu added <a href=\"https:\/\/git.kernel.org\/linus\/4fbfeb8bd684d564bddeff1e3723d3d9f99aa5de\">zeroing-on-failure testing<\/a>, and I expanded the <a href=\"https:\/\/git.kernel.org\/linus\/4c5d7bc63775b40631b75f6c59a3a3005455262d\">get_user()\/put_user() tests to include all sizes<\/a>. Neither improvement alone would have found the ARM bug, but together they uncovered a typo in a corner case.<\/p>\n<p><strong>no-new-privs visible in <code>\/proc\/$pid\/status<\/code><\/strong><br \/>\nThis is a tiny change, but I like being able to introspect processes externally. Prior to this, I wasn&#8217;t able to trivially answer the question &#8220;is that process setting the no-new-privs flag?&#8221; To address this, I <a href=\"https:\/\/git.kernel.org\/linus\/af884cd4a5ae62fcf5e321fecf0ec1014730353d\">exposed the flag in <code>\/proc\/$pid\/status<\/code><\/a>, as <code>NoNewPrivs<\/code>.<\/p>\n<p><strong>Kernel Userspace Execute Prevention on powerpc<\/strong><br \/>\nLike SMEP on x86 and PXN on ARM, Balbir Singh <a href=\"https:\/\/git.kernel.org\/linus\/3b10d0095a1e2d6ce11f6537e04806ff8aba9cdd\">implemented the protection on Power9<\/a> and later PPC CPUs under <code>CONFIG_PPC_RADIX_MMU=y<\/code> (which is the default). This means that if the kernel has a function pointer overwritten, it can no longer point into arbitrary code in userspace memory. An attacker&#8217;s ability is reduced to only using executable kernel memory, which is much less under their control (and has more limited visibility).<\/p>\n<p>That&#8217;s all for now! Please let me know if you saw anything else you think needs to be called out. :) I&#8217;m already excited about the <a href=\"\/blog\/archives\/2017\/05\/02\/security-things-in-linux-v4-11\/\">v4.11<\/a> merge window opening&#8230;<\/p>\n<p><em>Edit: Added note about SMEP on Power9<\/em><\/p>\n<p style='text-align:left'>&copy; 2017 &#8211; 2019, <a href=\"https:\/\/outflux.net\/blog\/\">Kees Cook<\/a>. This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">Creative Commons Attribution-ShareAlike 4.0 License<\/a>.<br \/><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><img decoding=\"async\" alt=\"CC BY-SA 4.0\" style=\"border-width:0\" src=\"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Previously: v4.9. Here&#8217;s a quick summary of some of the interesting security things in last week&#8217;s v4.10 release of the Linux kernel: PAN emulation on arm64 Catalin Marinas introduced ARM64_SW_TTBR0_PAN, which is functionally the arm64 equivalent of arm&#8217;s CONFIG_CPU_SW_DOMAIN_PAN. While Privileged eXecute Never (PXN) has been available in ARM hardware for a while now, Privileged [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,18,21,6,14,19],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/996"}],"collection":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/comments?post=996"}],"version-history":[{"count":16,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/996\/revisions"}],"predecessor-version":[{"id":1316,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/996\/revisions\/1316"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}