From: Peter Zijlstra Subject: Re: x86: PIE support and option to extend KASLR randomization Date: Mon, 21 Aug 2017 16:28:54 +0200 Message-ID: <20170821142854.dmuusnbc2tsrai3v@hirez.programming.kicks-ass.net> References: <20170810172615.51965-1-thgarnie@google.com> <20170811124127.kkb5pnkljz4umxuj@gmail.com> <20170815075609.mmzbfwritjzvrpsn@gmail.com> <20170816151235.oamkdva6cwpc4cex@gmail.com> <20170821133222.2ek6bhqgdeoymxsg@hirez.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Thomas Garnier , Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Josh Poimboeuf , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter To: Ingo Molnar Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Content-Disposition: inline In-Reply-To: <20170821133222.2ek6bhqgdeoymxsg@hirez.programming.kicks-ass.net> List-Id: linux-crypto.vger.kernel.org On Mon, Aug 21, 2017 at 03:32:22PM +0200, Peter Zijlstra wrote: > On Wed, Aug 16, 2017 at 05:12:35PM +0200, Ingo Molnar wrote: > > Unfortunately mcmodel=large looks pretty heavy too AFAICS, at the machine > > instruction level. > > > > Function calls look like this: > > > > -mcmodel=medium: > > > > 757: e8 98 ff ff ff callq 6f4 > > > > -mcmodel=large > > > > 77b: 48 b8 10 f7 df ff ff movabs $0xffffffffffdff710,%rax > > 782: ff ff ff > > 785: 48 8d 04 03 lea (%rbx,%rax,1),%rax > > 789: ff d0 callq *%rax > > > > And we'd do this for _EVERY_ function call in the kernel. That kind of crap is > > totally unacceptable. > > So why does this need to be computed for every single call? How often > will we move the kernel around at runtime? > > Why can't we process the relocation at load time and then discard the > relocation tables along with the rest of __init ? Ah, I see, this is large mode and that needs to use MOVABS to load 64bit immediates. Still, small RIP relative should be able to live at any point as long as everything lives inside the same 2G relative range, so would still allow the goal of increasing the KASLR range. So I'm not seeing how we need large mode for that. That said, after reading up on all this, RIP relative will not be too pretty either, while CALL is naturally RIP relative, data still needs an explicit %rip offset, still loads better than the large model.