From patchwork Fri Jun 23 20:59:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9807275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 941CA60349 for ; Fri, 23 Jun 2017 21:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86287285A8 for ; Fri, 23 Jun 2017 21:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7ACED2867F; Fri, 23 Jun 2017 21:00:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 7136B28737 for ; Fri, 23 Jun 2017 21:00:34 +0000 (UTC) Received: (qmail 17567 invoked by uid 550); 23 Jun 2017 21:00:23 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 17455 invoked from network); 23 Jun 2017 21:00:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aFhyF7vUQCDmmKsZJ2vA0s9CGplQIAbQDdF4eDaZ560=; b=gNl6KmRTWBZXhwHZ6OPxE7Sxb/UFCVzjniTAWre+2flJTBl8oV26hhNsVPc7MbRTI3 f9Hyp2Y0CBnpNwnL1i1S+aBm4GXCodpjRQeEhEWmejXxguYghoWXhZyqH2bSK2BuNcKY M49Fg4IWMZP5oGyWbBUId4qUN0zm5w1CFX6EA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aFhyF7vUQCDmmKsZJ2vA0s9CGplQIAbQDdF4eDaZ560=; b=qciWHbkqhnHATvM4aRE/E8xOo/3lkLF+HOnArjRcVtcbvJDK8bsEqlkKzfV9/fgAJr hkrXALvxqvv0XSx9dUI5TdDJsrgX1UkIl0wHIIo7moUdxHPLlGmhw1w+o2/02xar084t v+pPkFRAwjfkB+bmVD0pplWCbXnv+08pHypQyqj99qKcp4P+XbIPMeHD/jRBx5//44fb fbba85XDvHD+v4QENQgI4elKPGx+F4jLZ0eGaFmqN0y6Nw1YlA3wgjo9yk+DZo8G/Ag4 4uGk9znCY8r55OclvipMUqAD4ndHPmDOimoyE4DR7iLqzqZGB4qzDftJW7ln4gvLnvY/ CffA== X-Gm-Message-State: AKS2vOwOFujvVfsn7wIqw4LECFMoFxyHDnblgVb58PbUFnemCaoc9v31 lJ2LgAXRg9CBpvos X-Received: by 10.84.198.129 with SMTP id p1mr6612961pld.120.1498251610576; Fri, 23 Jun 2017 14:00:10 -0700 (PDT) From: Kees Cook To: Andrew Morton Cc: Kees Cook , stable@vger.kernel.org, Ard Biesheuvel , Catalin Marinas , Mark Rutland , Rik van Riel , Daniel Micay , Qualys Security Advisory , Russell King , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Alexander Viro , Pratyush Anand , James Hogan , Dmitry Safonov , Grzegorz Andrejczuk , Masahiro Yamada , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Fri, 23 Jun 2017 13:59:58 -0700 Message-Id: <1498251600-132458-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498251600-132458-1-git-send-email-keescook@chromium.org> References: <1498251600-132458-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v2 3/5] arm64: Move ELF_ET_DYN_BASE to 4GB / 4MB X-Virus-Scanned: ClamAV using ClamSMTP Now that explicitly executed loaders are loaded in the mmap region, we have more freedom to decide where we position PIE binaries in the address space to avoid possible collisions with mmap or stack regions. For 64-bit, align to 4GB to allow runtimes to use the entire 32-bit address space for 32-bit pointers. On 32-bit use 4MB, to match ARM. This could be 0x8000, the standard ET_EXEC load address, but that is needlessly close to the NULL address, and anyone running arm compat PIE will have an MMU, so the tight mapping is not needed. Cc: stable@vger.kernel.org Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: Mark Rutland Signed-off-by: Kees Cook --- arch/arm64/include/asm/elf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 5d1700425efe..8790fb09f689 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -113,12 +113,11 @@ #define ELF_EXEC_PAGESIZE PAGE_SIZE /* - * This is the location that an ET_DYN program is loaded if exec'ed. Typical - * use of this is to invoke "./ld.so someprog" to test out a new version of - * the loader. We need to make sure that it is out of the way of the program - * that it will "exec", and that there is sufficient room for the brk. + * This is the base location for PIE (ET_DYN with INTERP) loads. On + * 64-bit, this is raised to 4GB to leave the entire 32-bit address + * space open for things that want to use the area for 32-bit pointers. */ -#define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3) +#define ELF_ET_DYN_BASE 0x100000000UL #ifndef __ASSEMBLY__ @@ -173,7 +172,8 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #ifdef CONFIG_COMPAT -#define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) +/* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */ +#define COMPAT_ELF_ET_DYN_BASE 0x000400000UL /* AArch32 registers. */ #define COMPAT_ELF_NGREG 18