From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <1502900796.1302.52.camel@gmail.com> From: Daniel Micay Date: Wed, 16 Aug 2017 12:26:36 -0400 In-Reply-To: <20170816151235.oamkdva6cwpc4cex@gmail.com> References: <20170810172615.51965-1-thgarnie@google.com> <20170811124127.kkb5pnkljz4umxuj@gmail.com> <20170815075609.mmzbfwritjzvrpsn@gmail.com> <20170816151235.oamkdva6cwpc4cex@gmail.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [kernel-hardening] Re: x86: PIE support and option to extend KASLR randomization To: Ingo Molnar , Thomas Garnier Cc: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Paul Gortmaker , Chris Metcalf , Andrew Morton , "Paul E . McKenney" , Nicolas Pitre , Christopher Li , "Rafael J . Wysocki" , Lukas Wunner , Mika Westerberg , Dou Liyang , Daniel Borkmann , Alexei Starovoitov , Masahiro Yamada , Markus Trippelsdorf , Steven Rostedt , Kees Cook , Rik van Riel , David Howells , Waiman Long , Kyle Huey , Peter Foley , Tim Chen , Catalin Marinas , Ard Biesheuvel , Michal Hocko , Matthew Wilcox , "H . J . Lu" , Paul Bolle , Rob Landley , Baoquan He , the arch/x86 maintainers , linux-crypto@vger.kernel.org, LKML , xen-devel@lists.xenproject.org, kvm list , Linux PM list , linux-arch , linux-sparse@vger.kernel.org, Kernel Hardening , Linus Torvalds , Peter Zijlstra , Borislav Petkov List-ID: > How are these assumptions hardcoded by GCC? Most of the instructions > should be > relocatable straight away, as most call/jump/branch instructions are > RIP-relative. > > I.e. is there no GCC code generation mode where code can be placed > anywhere in the > canonical address space, yet call and jump distance is within 31 bits > so that the > generated code is fast? That's what PIE is meant to do. However, not disabling support for lazy linking (-fno-plt) / symbol interposition (-Bsymbolic) is going to cause it to add needless overhead. arm64 is using -pie -shared -Bsymbolic in arch/arm64/Makefile for their CONFIG_RELOCATABLE option. See 08cc55b2afd97a654f71b3bebf8bb0ec89fdc498. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Micay Subject: Re: x86: PIE support and option to extend KASLR randomization Date: Wed, 16 Aug 2017 12:26:36 -0400 Message-ID: <1502900796.1302.52.camel@gmail.com> References: <20170810172615.51965-1-thgarnie@google.com> <20170811124127.kkb5pnkljz4umxuj@gmail.com> <20170815075609.mmzbfwritjzvrpsn@gmail.com> <20170816151235.oamkdva6cwpc4cex@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: In-Reply-To: <20170816151235.oamkdva6cwpc4cex@gmail.com> To: Ingo Molnar , Thomas Garnier Cc: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph List-Id: linux-arch.vger.kernel.org > How are these assumptions hardcoded by GCC? Most of the instructions > should be > relocatable straight away, as most call/jump/branch instructions are > RIP-relative. > > I.e. is there no GCC code generation mode where code can be placed > anywhere in the > canonical address space, yet call and jump distance is within 31 bits > so that the > generated code is fast? That's what PIE is meant to do. However, not disabling support for lazy linking (-fno-plt) / symbol interposition (-Bsymbolic) is going to cause it to add needless overhead. arm64 is using -pie -shared -Bsymbolic in arch/arm64/Makefile for their CONFIG_RELOCATABLE option. See 08cc55b2afd97a654f71b3bebf8bb0ec89fdc498.