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: 9807319 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 83D9F60349 for ; Fri, 23 Jun 2017 21:06:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEE9B223C7 for ; Fri, 23 Jun 2017 21:06:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C241525F31; Fri, 23 Jun 2017 21:06:38 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47969223C7 for ; Fri, 23 Jun 2017 21:06:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=bJ9EbVHzftrZmxKnUfelUBOgF3PhHiBWMnj9b4buD6A=; b=tcT/OVQgEDIQ1jsu0BE/hozdH2 91MgZee9vfgP3PAfhQ2nzizZ+Asy/ZzohyN/TLixsvKIQyUYZ5MH39+jYmvEM5WVyhfBqli+EhB3f cjGTUExebpQmmueYBmuEx++MfR5EWI8CSHyxSIcd3ogOfkQTYZdi8d5bJfGikNORTpMMYQISRBnGL YZYQYnVza1Klv3posmx/ZV7CYXFsjjiqbuwiR8dCpm43YUpjPgX1hDslbNPvgpSO14BiDMP7JPBlx s35oyRvmJV6x2PeF0ywfXJg8tVOwtIU4opYzoSDdVnTw/BmylUaeF2BDciU9zvy9hiEu3+r7rbf8b /YN3mLTA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dOVmj-0001Oc-KW; Fri, 23 Jun 2017 21:06:33 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dOVgu-0007us-Qo for linux-arm-kernel@lists.infradead.org; Fri, 23 Jun 2017 21:00:34 +0000 Received: by mail-pf0-x229.google.com with SMTP id c73so28455683pfk.2 for ; Fri, 23 Jun 2017 14:00:11 -0700 (PDT) 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=oob7K/N4FAGIOKcaPWmnSa3YudnMcPXHfzE/jXuRHxzk1y/CRVT2QzU0avopnpqks4 BsjCs7H1+7VcAXSi2ipvz3rFPz5GGWDGAc/ke7K4SNInnc+armJEuBJ7ax3J1Effu+xQ MAD51+0Lpb0TU0ZB0KtncnXTO91bunvj5G7h9kxrt73WCww0jtt5pMrUC39f3S8kfkuD 51V6VNvD22t16tPkS5K2/YF8afuX2wXnNVvMmk4tWukt1JA+skBIWvBSjwjwtLd9Nw5k eJh26rOGqCna4B0jX+NkrZde9+HnQVwRz1NkEPD7jseHiZuDfp8ASsTEBqPRbdym39y2 p9xA== X-Gm-Message-State: AKS2vOxymqKRgHn7H9kkeTPicKfOwrwnpIim4i730ABeu6aJJyFWaTFp upS6le9kUJK72JYb X-Received: by 10.84.198.129 with SMTP id p1mr6612961pld.120.1498251610576; Fri, 23 Jun 2017 14:00:10 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id t82sm11788291pfe.88.2017.06.23.14.00.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2017 14:00:08 -0700 (PDT) From: Kees Cook To: Andrew Morton Subject: [PATCH v2 3/5] arm64: Move ELF_ET_DYN_BASE to 4GB / 4MB 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170623_140032_907302_8D1A2ED4 X-CRM114-Status: GOOD ( 15.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Grzegorz Andrejczuk , kernel-hardening@lists.openwall.com, Catalin Marinas , Heiko Carstens , Masahiro Yamada , Paul Mackerras , "H. Peter Anvin" , Pratyush Anand , linux-s390@vger.kernel.org, Michael Ellerman , x86@kernel.org, Russell King , Ingo Molnar , Benjamin Herrenschmidt , Qualys Security Advisory , Rik van Riel , James Hogan , Kees Cook , Will Deacon , linux-fsdevel@vger.kernel.org, Alexander Viro , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Dmitry Safonov , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Micay , Martin Schwidefsky , linuxppc-dev@lists.ozlabs.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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