From patchwork Fri Jun 23 21:00:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9807321 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 1257760349 for ; Fri, 23 Jun 2017 21:06:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB3B0223C7 for ; Fri, 23 Jun 2017 21:06:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FA19285C3; Fri, 23 Jun 2017 21:06:48 +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 EB111285B1 for ; Fri, 23 Jun 2017 21:06:47 +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=4HRaAWwchz+fAnPc2F5dLbyhJR5sp4/7kxU7NlSKNhA=; b=ERs9bm3qxp8u4DH13kKAwv0h27 FxgTt4dL7s1Ou59ibBIjzGAWtRx2hSzmQagPosJdQQVuJeHwrgHqIJCDQcYOSMmmN+vwaWi9xeriF /zHxhloXkH7JHkXBMCIe+v2YCyfigAiezTQTwKGc6GpMK2jQ0EIJ5rvmnAuASqYurbvoSdx/E11fV bM5tdKao9dvfzbRuL6QxPXUU/3L6xsBH/LRrqBwv8e4SEkiK2s92sj45x41bRHATU48g/CuugzL67 HyhCyZ7QFi6VanrktNW7vt2QzQ5pR7nKOJMFzhEpP8hJrwAewN+gSM1ADQi93QcvWfKqmMrKVwqxh fykfkBfg==; 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 1dOVms-0001ZN-E4; Fri, 23 Jun 2017 21:06:42 +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-0007ux-Qp 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 q86so28427217pfl.3 for ; Fri, 23 Jun 2017 14:00:13 -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=zBIiXrk+YofUPuLgYDPuLoP7g64X/OUjZ6JPAGlVWCs=; b=KrKSNJqZPxM43KVml7gTicDCEOBGczNdscmTlxU84XFEg/yl2lCY1wiRl9W+RSe3kg hLfmsGnCt7txfeXpQAyfAnOGfv+xiLb1rH4zIRhzrVYPGDrbgZ6rFdZjH+16eRpc/LmW OVeglsapilaq5UvXw24Yp631HhFfoWAB8YhZE= 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=zBIiXrk+YofUPuLgYDPuLoP7g64X/OUjZ6JPAGlVWCs=; b=q5QY4xALxz3yNsMgekkl15kgWE637BAgjcez/w8VwZHA0tMywgQ8b1sJLIym33cSMq XMwpH15dIs6ZYxamne5oO4wr3FWkNLiwSEuv0p67B7ktQq4PlBIcq36nLO3UaxBqUgWD jCIYaKoGFYHaDJf3sCkhcC/fz5aein1Vwlf7WiOyWUL6IMcUQAf5pyyOmCWvp4Yd8+w7 hmkkEAYSAHOXi1N+xY0USOgVtUFrbApwSRR3VO0t3B/9cAGuswcACqOQ9KucJi7N1+Dh 2g7qbTKFLKh2TUJMTjIgc7PoirUJi0lsVc3twS2FvWpgK/gRURqYsS8eVAJndwaeI2PC /NCA== X-Gm-Message-State: AKS2vOywkM5CsTUC/H78W/Z9cr/7x87SZmhSVzphCcmBoSHaeig+sjx/ edoBz/pentcgDqV2 X-Received: by 10.99.105.74 with SMTP id e71mr9856875pgc.51.1498251613617; Fri, 23 Jun 2017 14:00:13 -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 p73sm11827318pfd.79.2017.06.23.14.00.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2017 14:00:12 -0700 (PDT) From: Kees Cook To: Andrew Morton Subject: [PATCH v2 5/5] s390: Move ELF_ET_DYN_BASE to 4GB / 4MB Date: Fri, 23 Jun 2017 14:00:00 -0700 Message-Id: <1498251600-132458-6-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_889618_00B6BC1A X-CRM114-Status: GOOD ( 15.91 ) 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: 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, which is the traditional x86 minimum load location, likely to avoid historically requiring a 4MB page table entry when only a portion of the first 4MB would be used (since the NULL address is avoided). For s390 the position could be 0x10000, but that is needlessly close to the NULL address. Cc: stable@vger.kernel.org Cc: Heiko Carstens Cc: Martin Schwidefsky Signed-off-by: Kees Cook --- arch/s390/include/asm/elf.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index e8f623041769..7c58d599f91b 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h @@ -161,14 +161,13 @@ extern unsigned int vdso_enabled; #define CORE_DUMP_USE_REGSET #define ELF_EXEC_PAGESIZE 4096 -/* 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. 64-bit - tasks are aligned to 4GB. */ -#define ELF_ET_DYN_BASE (is_compat_task() ? \ - (STACK_TOP / 3 * 2) : \ - (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1)) +/* + * 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 (is_compat_task() ? 0x000400000UL : \ + 0x100000000UL) /* This yields a mask that user programs can use to figure out what instruction set this CPU supports. */