{"id":1028,"date":"2017-07-10T01:24:23","date_gmt":"2017-07-10T08:24:23","guid":{"rendered":"https:\/\/outflux.net\/blog\/?p=1028"},"modified":"2017-11-20T11:15:48","modified_gmt":"2017-11-20T19:15:48","slug":"security-things-in-linux-v4-12","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2017\/07\/10\/security-things-in-linux-v4-12\/","title":{"rendered":"security things in Linux v4.12"},"content":{"rendered":"<p>Previously: <a href=\"\/blog\/archives\/2017\/05\/02\/security-things-in-linux-v4-11\/\">v4.11<\/a>.<\/p>\n<p>Here\u2019s a quick summary of some of the interesting security things in last week\u2019s v4.12 release of the Linux kernel:<\/p>\n<p><strong>x86 read-only and fixed-location GDT<\/strong><br \/>\nWith <a href=\"\/blog\/archives\/2016\/10\/04\/security-things-in-linux-v4-8\/\">kernel memory base randomization<\/a>, it was stil possible to figure out the per-cpu base address via the &#8220;sgdt&#8221; instruction, since it would reveal the per-cpu GDT location. To solve this, Thomas Garnier moved the GDT to a <a href=\"https:\/\/git.kernel.org\/linus\/69218e47994da614e7af600bf06887750ab6657a\">fixed location<\/a>. And to solve the risk of an attacker targeting the GDT directly with a kernel bug, he also made it <a href=\"https:\/\/git.kernel.org\/linus\/45fc8757d1d2128e342b4e7ef39adedf7752faac\">read-only<\/a>.<\/p>\n<p><strong>usercopy consolidation<\/strong><br \/>\nAfter <a href=\"\/blog\/archives\/2016\/10\/04\/security-things-in-linux-v4-8\/\">hardened usercopy<\/a> landed, Al Viro decided to take a closer look at all the usercopy routines and then <a href=\"https:\/\/git.kernel.org\/linus\/eea86b637a15bc4d4bd518b11330ac96baa6b73d\">consolidated the per-architecture uaccess code<\/a> into a single implementation. The per-architecture code was functionally very similar to each other, so it made sense to remove the redundancy. In the process, he uncovered a number of unhandled corner cases in various architectures (that got fixed by the consolidation), and made <a href=\"https:\/\/git.kernel.org\/linus\/2fefc97b2180518bac923fba3f79fdca1f41dc15\">hardened usercopy available on all remaining architectures<\/a>.<\/p>\n<p><strong>ASLR entropy sysctl on PowerPC<\/strong><br \/>\nContinuing to expand architecture support for the <a href=\"\/blog\/archives\/2016\/09\/28\/security-things-in-linux-v4-5\/\">ASLR entropy sysctl<\/a>, Michael Ellerman implemented the <a href=\"https:\/\/git.kernel.org\/linus\/9fea59bd7ca541e5d0851f0b6dbca83c60ea90cd\">calculations needed for PowerPC<\/a>. This lets userspace choose to crank up the entropy used for memory layouts.<\/p>\n<p><strong>LSM structures read-only<\/strong><br \/>\nJames Morris used <a href=\"\/blog\/archives\/2016\/09\/30\/security-things-in-linux-v4-6\/\"><code>__ro_after_init<\/code><\/a> to make the <a href=\"https:\/\/git.kernel.org\/linus\/ca97d939db114c8d1619e10a3b82af8615372dae\">LSM structures read-only after boot<\/a>. This removes them as a desirable target for attackers. Since the hooks are called from all kinds of places in the kernel this was a favorite method for attackers to use to hijack execution of the kernel. (A similar target used to be the system call table, but that has long since been made read-only.) Be wary that <code>CONFIG_SECURITY_SELINUX_DISABLE<\/code> removes this protection, so make sure that config stays disabled.<\/p>\n<p><strong>KASLR enabled by default on x86<\/strong><br \/>\nWith many distros already enabling <a href=\"\/blog\/archives\/2016\/10\/04\/security-things-in-linux-v4-8\/\">KASLR<\/a> on x86 with <code>CONFIG_RANDOMIZE_BASE<\/code> and <code>CONFIG_RANDOMIZE_MEMORY<\/code>, Ingo Molnar felt the feature was mature enough to be <a href=\"https:\/\/git.kernel.org\/linus\/6807c84652b0b7e2e198e50a9ad47ef41b236e59\">enabled by default<\/a>.<\/p>\n<p><strong>Expand stack canary to 64 bits on 64-bit systems<\/strong><br \/>\nThe stack canary values used by <a href=\"\/blog\/archives\/2014\/01\/27\/fstack-protector-strong\/\"><code>CONFIG_CC_STACKPROTECTOR<\/code><\/a> is most powerful on x86 since it is different per task. (Other architectures run with a single canary for all tasks.) While the first canary chosen on x86 (and other architectures) was a full <code>unsigned long<\/code>, the subsequent canaries chosen per-task for x86 were being truncated to 32-bits. Daniel Micay <a href=\"https:\/\/git.kernel.org\/linus\/5ea30e4e58040cfd6434c2f33dc3ea76e2c15b05\">fixed this<\/a> so now x86 (and future architectures that gain per-task canary support) have significantly increased entropy for stack-protector.<\/p>\n<p><strong>Expanded stack\/heap gap<\/strong><br \/>\nHugh Dickens, with input from many other folks, <a href=\"https:\/\/git.kernel.org\/linus\/1be7107fbe18eed3e319a6c3e83c78254b693acb\">improved the kernel&#8217;s mitigation<\/a> against having the stack and heap crash into each other. This is a stop-gap measure to help defend against the <a href=\"https:\/\/www.qualys.com\/2017\/06\/19\/stack-clash\/stack-clash.txt\">Stack Clash<\/a> attacks. Additional hardening needs to come from the compiler to produce &#8220;stack probes&#8221; when doing large stack expansions. Any Variable Length Arrays on the stack or <code>alloca()<\/code> usage needs to have machine code generated to touch each page of memory within those areas to let the kernel know that the stack is expanding, but with single-page granularity.<\/p>\n<p>That\u2019s it for now; please let me know if I missed anything. The <a href=\"\/blog\/archives\/2017\/09\/05\/security-things-in-linux-v4-13\/\">v4.13<\/a> merge window is open!<\/p>\n<p>Edit: Brad Spengler pointed out that I failed to mention the <code>CONFIG_SECURITY_SELINUX_DISABLE<\/code> issue with read-only LSM structures. This has been added now.<\/p>\n<p style='text-align:left'>&copy; 2017, <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.11. Here\u2019s a quick summary of some of the interesting security things in last week\u2019s v4.12 release of the Linux kernel: x86 read-only and fixed-location GDT With kernel memory base randomization, it was stil possible to figure out the per-cpu base address via the &#8220;sgdt&#8221; instruction, since it would reveal the per-cpu GDT location. [&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\/1028"}],"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=1028"}],"version-history":[{"count":11,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/1028\/revisions"}],"predecessor-version":[{"id":1091,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/1028\/revisions\/1091"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=1028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=1028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=1028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}