From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757366AbbCCSD3 (ORCPT ); Tue, 3 Mar 2015 13:03:29 -0500 Received: from mail-vc0-f172.google.com ([209.85.220.172]:63334 "EHLO mail-vc0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757225AbbCCSDY (ORCPT ); Tue, 3 Mar 2015 13:03:24 -0500 MIME-Version: 1.0 In-Reply-To: <20150303073132.GA30602@gmail.com> References: <1425341988-1599-1-git-send-email-keescook@chromium.org> <20150303073132.GA30602@gmail.com> Date: Tue, 3 Mar 2015 10:03:22 -0800 X-Google-Sender-Auth: se5ehG526z39YexVad368x3q8rY Message-ID: Subject: Re: [PATCH v2 0/5] split ET_DYN ASLR from mmap ASLR From: Kees Cook To: Ingo Molnar Cc: Andrew Morton , LKML , Russell King , Catalin Marinas , Will Deacon , Ralf Baechle , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , linux390@de.ibm.com, "x86@kernel.org" , Alexander Viro , Oleg Nesterov , Andy Lutomirski , "David A. Long" , Andrey Ryabinin , Arun Chandran , Yann Droneaud , Min-Hua Chen , Paul Burton , Alex Smith , Markos Chandras , Jeff Bailey , Vineeth Vijayan , Michael Holzheu , Ben Hutchings , Hector Marco-Gisbert , Borislav Petkov , =?UTF-8?Q?Jan=2DSimon_M=C3=B6ller?= , "linux-arm-kernel@lists.infradead.org" , Linux MIPS Mailing List , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, "linux-fsdevel@vger.kernel.org" , Linus Torvalds , Borislav Petkov , "H. Peter Anvin" , Thomas Gleixner 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, Mar 2, 2015 at 11:31 PM, Ingo Molnar wrote: > > * Kees Cook wrote: > >> To address the "offset2lib" ASLR weakness[1], this separates ET_DYN >> ASLR from mmap ASLR, as already done on s390. The architectures >> that are already randomizing mmap (arm, arm64, mips, powerpc, s390, >> and x86), have their various forms of arch_mmap_rnd() made available >> via the new CONFIG_ARCH_HAS_ELF_RANDOMIZE. For these architectures, >> arch_randomize_brk() is collapsed as well. >> >> This is an alternative to the solutions in: >> https://lkml.org/lkml/2015/2/23/442 > > Looks good so far: > > Reviewed-by: Ingo Molnar > > While reviewing this series I also noticed that the following code > could be factored out from architecture mmap code as well: > > - arch_pick_mmap_layout() uses very similar patterns across the > platforms, with only few variations. Many architectures use > the same duplicated mmap_is_legacy() helper as well. There's > usually just trivial differences between mmap_legacy_base() > approaches as well. I was nervous to start refactoring this code, but it's true: most of it is the same. > - arch_mmap_rnd(): the PF_RANDOMIZE checks are needlessly > exposed to the arch routine - the arch routine should only > concentrate on arch details, not generic flags like > PF_RANDOMIZE. Yeah, excellent point. I will send a follow-up patch to move this into binfmt_elf instead. I'd like to avoid removing it in any of the other patches since each was attempting a single step in the refactoring. > In theory the mmap layout could be fully parametrized as well: i.e. no > callback functions to architectures by default at all: just > declarations of bits of randomization desired (or, available address > space bits), and perhaps an arch helper to allow 32-bit vs. 64-bit > address space distinctions. Yeah, I was considering that too, since each architecture has a nearly identical arch_mmap_rnd() at this point. Only the size of the entropy was changing. > 'Weird' architectures could provide special routines, but only by > overriding the default behavior, which should be generic, safe and > robust. Yeah, quite true. Should entropy size be a #define like ELF_ET_DYN_BASE? Something like ASLR_MMAP_ENTROPY and ASLR_MMAP_ENTROPY_32? Is there a common function for determining a compat task? That seemed to be per-arch too. Maybe arch_mmap_entropy()? -Kees -- Kees Cook Chrome OS Security