From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755180AbaLVUNq (ORCPT ); Mon, 22 Dec 2014 15:13:46 -0500 Received: from mail-la0-f49.google.com ([209.85.215.49]:64678 "EHLO mail-la0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754858AbaLVUNp (ORCPT ); Mon, 22 Dec 2014 15:13:45 -0500 MIME-Version: 1.0 In-Reply-To: References: <5489E6D2.2060200@upv.es> <5489FAAD.7000606@upv.es> <20141211221158.GS18807@outflux.net> <548B18AC.9@upv.es> <5494A0DF.10905@upv.es> <20141222183615.4193722q3opf4uj3@webmail.upv.es> From: Andy Lutomirski Date: Mon, 22 Dec 2014 12:13:22 -0800 Message-ID: Subject: Re: [PATCH] ASLRv3: randomize_va_space=3 preventing offset2lib attack To: Jiri Kosina Cc: Hector Marco Gisbert , Cyrill Gorcunov , Pavel Emelyanov , Catalin Marinas , Heiko Carstens , Oleg Nesterov , Ingo Molnar , Anton Blanchard , Russell King - ARM Linux , "H. Peter Anvin" , David Daney , Andrew Morton , Arun Chandran , "linux-kernel@vger.kernel.org" , Martin Schwidefsky , Ismael Ripoll , Christian Borntraeger , Thomas Gleixner , =?UTF-8?Q?Hanno_B=C3=B6ck?= , Will Deacon , Benjamin Herrenschmidt , Kees Cook , Reno Robert Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 22, 2014 at 12:03 PM, Jiri Kosina wrote: > On Mon, 22 Dec 2014, Andy Lutomirski wrote: > >> It could be worth having a mode that goes all out: randomize every >> single allocation independently in, say, a 45 or 46-byte range. That >> would be about as strong ASLR as we could possibly have, it would >> result in guard intervals around mmap data allocations (which has real >> value), and it would still leave plenty of space for big address space >> hogs like the Chromium sandbox. >> >> The main downside would be lots of memory used for page tables. > > Plus get_random_int() during every mmap() call. If that's actually a problem, then I think we should fix get_random_int. Chacha20 can generate 64 bits in a few cycles. > Plus the resulting VA > space fragmentation. I think the main cost of fragmentation would be the page tables and vmas. 2^45 bytes is a lot of bytes. We could tone it down a bit if we dedicated a range to mmapped data and tried to pack it reasonably densely. We could even do a fair amount of merging for data-heavy applications if we gave MAP_PRIVATE | MAP_ANONYMOUS, PROT_READ | PROT_WRITE mappings a decent chance of ending up next to each other. Anyway, this would be a knob. The database people would presumably turn it off. --Andy