{"id":1438,"date":"2020-09-02T16:22:25","date_gmt":"2020-09-02T23:22:25","guid":{"rendered":"https:\/\/outflux.net\/blog\/?p=1438"},"modified":"2022-04-04T14:08:00","modified_gmt":"2022-04-04T21:08:00","slug":"security-things-in-linux-v5-6","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2020\/09\/02\/security-things-in-linux-v5-6\/","title":{"rendered":"security things in Linux v5.6"},"content":{"rendered":"<p>Previously: <a href=\"\/blog\/archives\/2020\/05\/27\/security-things-in-linux-v5-5\/\">v5.5<\/a>.<\/p>\n<p>Linux <a href=\"https:\/\/lore.kernel.org\/lkml\/CAHk-=wi9ZT7Stg-uSpX0UWQzam6OP9Jzz6Xu1CkYu1cicpD5OA@mail.gmail.com\/\">v5.6 was released back in March<\/a>. Here&#8217;s my quick summary of various features that caught my attention:<\/p>\n<p><strong>WireGuard<\/strong><br \/>\nThe widely used <a href=\"https:\/\/www.wireguard.com\/\">WireGuard VPN<\/a> has been out-of-tree for a very long time. After 3 1\/2 years since its initial <a href=\"https:\/\/lore.kernel.org\/lkml\/CAHmME9q-6ioctzcB8gLdYOsMFqHVGY8GUsVGFisKv=wGdVqi2A@mail.gmail.com\/\">upstream RFC<\/a>, Ard Biesheuvel and Jason Donenfeld finished the work getting all the <a href=\"https:\/\/lore.kernel.org\/linux-crypto\/20191108122240.28479-1-ardb@kernel.org\/\">crypto prerequisites sorted out<\/a> for the v5.5 kernel. For this release, Jason has gotten <a href=\"https:\/\/git.kernel.org\/linus\/e7096c131e5161fa3b8e52a650d7719d2857adfd\">WireGuard itself landed<\/a>. It was a twisty road, and I&#8217;m grateful to everyone involved for sticking it out and navigating the compromises and alternative solutions.<\/p>\n<p><strong><code>openat2()<\/code> syscall and <code>RESOLVE_*<\/code> flags<\/strong><br \/>\nAleksa Sarai has added a number of important path resolution &#8220;scoping&#8221; options to the kernel&#8217;s <code>open()<\/code> handling, covering things like not walking above a specific point in a path hierarchy (<a href=\"https:\/\/git.kernel.org\/linus\/adb21d2b526f7f196b2f3fdca97d80ba05dd14a0\"><code>RESOLVE_BENEATH<\/code><\/a>), disabling the resolution of various &#8220;magic links&#8221; (<a href=\"https:\/\/git.kernel.org\/linus\/4b99d4996979d582859c5a49072e92de124bf691\"><code>RESOLVE_NO_MAGICLINKS<\/code><\/a>) in procfs (e.g. <code>\/proc\/$pid\/exe<\/code>) and other pseudo-filesystems, and treating a given lookup as happening relative to a different root directory (as if it were in a chroot, <a href=\"https:\/\/git.kernel.org\/linus\/8db52c7e7ee1bd861b6096fcafc0fe7d0f24a994\"><code>RESOLVE_IN_ROOT<\/code><\/a>). As part of this, it became clear that there wasn&#8217;t a way to correctly extend the existing <code>openat()<\/code> syscall, so he <a href=\"https:\/\/git.kernel.org\/linus\/fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179\">added <code>openat2()<\/code><\/a> (which is a good example of the efforts being made to codify <a href=\"https:\/\/lwn.net\/Articles\/822256\/\">&#8220;Extensible Syscall&#8221; arguments<\/a>). The <code>RESOLVE_*<\/code> set of flags also cover prior behaviors like <code>RESOLVE_NO_XDEV<\/code> and <code>RESOLVE_NO_SYMLINKS<\/code>.<\/p>\n<p><strong><code>pidfd_getfd()<\/code> syscall<\/strong><br \/>\nIn the continuing growth of the much-needed pidfd APIs, Sargun Dhillon has added the <a href=\"https:\/\/git.kernel.org\/linus\/8649c322f75c96e7ced2fec201e123b2b073bf09\"><code>pidfd_getfd()<\/code> syscall<\/a> which is a way to gain access to file descriptors of a process in a race-less way (or when <code>\/proc<\/code> is not mounted). Before, it wasn&#8217;t always possible make sure that opening file descriptors via <code>\/proc\/$pid\/fd\/$N<\/code> was actually going to be associated with the correct PID. Much more detail about this has been <a href=\"https:\/\/lwn.net\/Articles\/808997\/\">written up at LWN<\/a>.<\/p>\n<p><strong><code>openat()<\/code> via io_uring<\/strong><br \/>\nWith my &#8220;attack surface reduction&#8221; hat on, I remain personally suspicious of the <code>io_uring()<\/code> family of APIs, but I can&#8217;t deny their utility for certain kinds of workloads. Being able to pipeline reads and writes without the overhead of actually making syscalls is pretty great for performance. Jens Axboe has <a href=\"https:\/\/git.kernel.org\/linus\/15b71abe7b52df214785dde0de9f581cc0216d17\">added the IORING_OP_OPENAT command<\/a> so that existing io_urings can open files to be added on the fly to the mapping of available read\/write targets of a given io_uring. While LSMs are still happily able to intercept these actions, I remain wary of the growing &#8220;syscall multiplexer&#8221; that io_uring is becoming. I am, of course, glad to see that it has a comprehensive (if &#8220;out of tree&#8221;) <a href=\"https:\/\/github.com\/axboe\/liburing\/tree\/master\/test\">test suite as part of <code>liburing<\/code><\/a>.<\/p>\n<p><strong>removal of blocking random pool<\/strong><br \/>\nAfter making algorithmic changes to obviate separate entropy pools for random numbers, Andy Lutomirski <a href=\"https:\/\/git.kernel.org\/linus\/90ea1c6436d26e62496616fb5891e00819ff4849\">removed the blocking random pool<\/a>. This simplifies the kernel pRNG code significantly without compromising the userspace interfaces designed to fetch &#8220;cryptographically secure&#8221; random numbers. To quote Andy, &#8220;This series should not break any existing programs. <code>\/dev\/urandom<\/code> is unchanged. <code>\/dev\/random<\/code> will still block just after booting, but it will block less than it used to.&#8221; See LWN for more details on the <a href=\"https:\/\/lwn.net\/Articles\/808575\/\">history and discussion of the series<\/a>.<\/p>\n<p><strong>arm64 support for on-chip RNG<\/strong><br \/>\nMark Brown added <a href=\"https:\/\/git.kernel.org\/linus\/2e8e1ea88cbcb19a77b7acb67f6ffe39cc15740c\">support for the future ARMv8.5&#8217;s RNG<\/a> (<code>SYS_RNDR_EL0<\/code>), which is, from the kernel&#8217;s perspective, similar to x86&#8217;s <code>RDRAND<\/code> instruction. This will provide a bootloader-independent way to add entropy to the kernel&#8217;s pRNG for early boot randomness (e.g. stack canary values, memory ASLR offsets, etc). Until folks are running on ARMv8.5 systems, they can continue to depend on the bootloader for randomness (via the <a href=\"\/blog\/archives\/2017\/02\/27\/security-things-in-linux-v4-10\/\">UEFI RNG interface<\/a>) on arm64.<\/p>\n<p><strong>arm64 E0PD<\/strong><br \/>\nMark Brown added <a href=\"https:\/\/git.kernel.org\/linus\/3e6c69a058deaa50d33c3dac36cde80b4ce590e8\">support for the future ARMv8.5&#8217;s E0PD feature<\/a> (<code>TCR_E0PD1<\/code>), which causes all memory accesses from userspace into kernel space to fault in constant time. This is an attempt to remove any possible timing side-channel signals when probing kernel memory layout from userspace, as an alternative way to protect against Meltdown-style attacks. The expectation is that E0PD would be used instead of the more expensive Kernel Page Table Isolation (KPTI) features on arm64.<\/p>\n<p><strong>powerpc32 VMAP_STACK<\/strong><br \/>\nChristophe Leroy added <a href=\"https:\/\/git.kernel.org\/linus\/cd08f109e26231b279bcc0388428afcac6408ec6\">VMAP_STACK support to powerpc32<\/a>, joining x86, arm64, and s390. This helps protect against the various classes of attacks that depend on exhausting the kernel stack in order to collide with neighboring kernel stacks. (Another common target, the sensitive <code>thread_info<\/code>, had already been <a href=\"https:\/\/git.kernel.org\/linus\/ed1cd6deb013a11959d17a94e35ce159197632da\">moved away from the bottom of the stack<\/a> by Christophe Leroy in Linux v5.1.)<\/p>\n<p><strong>generic Page Table dumping<\/strong><br \/>\nRelated to RISCV&#8217;s work to add page table dumping (via <code>\/sys\/fs\/debug\/kernel_page_tables<\/code>), Steven Price extracted the existing implementations from multiple architectures and created a <a href=\"https:\/\/git.kernel.org\/linus\/30d621f6723b1c98a142861f7a52849d286bc7fa\">common page table dumping framework<\/a> (and then <a href=\"https:\/\/lore.kernel.org\/linux-arm-kernel\/20191218162402.45610-1-steven.price@arm.com\/\">refactored all the other architectures to use it<\/a>). I&#8217;m delighted to have this because I still remember when not having a working page table dumper for ARM delayed me for a while when trying to implement upstream kernel memory protections there. Anything that makes it easier for architectures to get their kernel memory protection working correctly makes me happy.<\/p>\n<p>That&#8217;s in for now; let me know if there&#8217;s anything you think I missed. Next up: Linux <a href=\"\/blog\/archives\/2020\/09\/21\/security-things-in-linux-v5-7\/\">v5.7<\/a>.<\/p>\n<p style='text-align:left'>&copy; 2020 &#8211; 2022, <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: v5.5. Linux v5.6 was released back in March. Here&#8217;s my quick summary of various features that caught my attention: WireGuard The widely used WireGuard VPN has been out-of-tree for a very long time. After 3 1\/2 years since its initial upstream RFC, Ard Biesheuvel and Jason Donenfeld finished the work getting all the crypto [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,20,18,21,6,14,19],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/1438"}],"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=1438"}],"version-history":[{"count":17,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/1438\/revisions"}],"predecessor-version":[{"id":1571,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/1438\/revisions\/1571"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=1438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=1438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=1438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}