Message ID | 20170810172615.51965-8-thgarnie@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <kernel-hardening-return-9316-patchwork-kernel-hardening=patchwork.kernel.org@lists.openwall.com> 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 6B02A60236 for <patchwork-kernel-hardening@patchwork.kernel.org>; Thu, 10 Aug 2017 17:28:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51948286CF for <patchwork-kernel-hardening@patchwork.kernel.org>; Thu, 10 Aug 2017 17:28:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 456A0288A7; Thu, 10 Aug 2017 17:28:49 +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_ADSP_CUSTOM_MED, 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 793C6286CF for <patchwork-kernel-hardening@patchwork.kernel.org>; Thu, 10 Aug 2017 17:28:48 +0000 (UTC) Received: (qmail 32623 invoked by uid 550); 10 Aug 2017 17:27:09 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: <mailto:kernel-hardening@lists.openwall.com> List-Help: <mailto:kernel-hardening-help@lists.openwall.com> List-Unsubscribe: <mailto:kernel-hardening-unsubscribe@lists.openwall.com> List-Subscribe: <mailto:kernel-hardening-subscribe@lists.openwall.com> List-ID: <kernel-hardening.lists.openwall.com> Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 32477 invoked from network); 10 Aug 2017 17:27:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XcdugCyINexHhiuz1aJf0Zvnvb6BthqzjaCDG+vK5o4=; b=pa00BV+l9uDoQD+3WqoWqn5UX/fWPCZ3dwTLWF3MPXfSc65pb3T+XYXZ7ut4IrMpk1 G8JMWgqLuspS3pLhv7N1sApG6aj5SN5oMwW/LKW03Fo0xdFmmvkou3Yx0amgF8gOQLqn EUW7TWxWAyalvNJMGbj2U2WtvkcEM7IY6h05AoG5fQVxqL4EH3+jTWY+5H2CzAA45QPS qPCWFTlPyzcMbUkemavdTwEJTfAbe2Z4WLPGUHDoOPZ8sw0PoDQZMfpVbecHWR1/YiHX vGcXk4v1OL+aTUxT2TkBYOcA8pcB4RpGx2dsOzAw3VCygfeGDmEl6BAr/F51w/C4nDrE Farw== 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=XcdugCyINexHhiuz1aJf0Zvnvb6BthqzjaCDG+vK5o4=; b=B16qKbwqplTvcbpOdzTeZUXzYr6r4TAx/0GNPtK6KqjXQdwdgsHA2BFj2TjGVhsUGC At4aCzD8WDr2LhlgT5R6agf/SssJ+M4HPloUl8aWK3EgWTXbDmHHsmBDiM22UnTDH28R cPhOXwA2zoDstpMxQv5fwFL9om5gD0DOVtwgqsMNfR7ZhhHQGa+MZAC/VSoGkU/sqI5W ciHu/TEtZrdiVCJQS5vytPp1AKOE3HNMJGVjY0uGdxrBdmHJIlis2Iw+4GiSeGlYiMTl LBWOp2xDKyghcV7Dk39XTyo+v/sPdGqgr5TP6/1R3Iwq9Qkb2Qux0o0GcBXYddhhvaxM ax4Q== X-Gm-Message-State: AHYfb5iPunznFvAUJl16qmQVNRpPVQ+zKo1EB388hccEgIxW6/LXKLtI c4+oVmi6rFWkxqf5 X-Received: by 10.98.200.151 with SMTP id i23mr13125624pfk.281.1502386013510; Thu, 10 Aug 2017 10:26:53 -0700 (PDT) From: Thomas Garnier <thgarnie@google.com> To: Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller" <davem@davemloft.net>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>, Peter Zijlstra <peterz@infradead.org>, Josh Poimboeuf <jpoimboe@redhat.com>, Arnd Bergmann <arnd@arndb.de>, Thomas Garnier <thgarnie@google.com>, Matthias Kaehlcke <mka@chromium.org>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, Juergen Gross <jgross@suse.com>, Paolo Bonzini <pbonzini@redhat.com>, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= <rkrcmar@redhat.com>, Joerg Roedel <joro@8bytes.org>, Tom Lendacky <thomas.lendacky@amd.com>, Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@suse.de>, Brian Gerst <brgerst@gmail.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, "Rafael J . Wysocki" <rjw@rjwysocki.net>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>, Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>, Paul Gortmaker <paul.gortmaker@windriver.com>, Chris Metcalf <cmetcalf@mellanox.com>, Andrew Morton <akpm@linux-foundation.org>, "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>, Nicolas Pitre <nicolas.pitre@linaro.org>, Christopher Li <sparse@chrisli.org>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>, Lukas Wunner <lukas@wunner.de>, Mika Westerberg <mika.westerberg@linux.intel.com>, Dou Liyang <douly.fnst@cn.fujitsu.com>, Daniel Borkmann <daniel@iogearbox.net>, Alexei Starovoitov <ast@kernel.org>, Masahiro Yamada <yamada.masahiro@socionext.com>, Markus Trippelsdorf <markus@trippelsdorf.de>, Steven Rostedt <rostedt@goodmis.org>, Kees Cook <keescook@chromium.org>, Rik van Riel <riel@redhat.com>, David Howells <dhowells@redhat.com>, Waiman Long <longman@redhat.com>, Kyle Huey <me@kylehuey.com>, Peter Foley <pefoley2@pefoley.com>, Tim Chen <tim.c.chen@linux.intel.com>, Catalin Marinas <catalin.marinas@arm.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Michal Hocko <mhocko@suse.com>, Matthew Wilcox <mawilcox@microsoft.com>, "H . J . Lu" <hjl.tools@gmail.com>, Paul Bolle <pebolle@tiscali.nl>, Rob Landley <rob@landley.net>, Baoquan He <bhe@redhat.com>, Daniel Micay <danielmicay@gmail.com> Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Thu, 10 Aug 2017 10:25:59 -0700 Message-Id: <20170810172615.51965-8-thgarnie@google.com> X-Mailer: git-send-email 2.14.0.434.g98096fd7a8-goog In-Reply-To: <20170810172615.51965-1-thgarnie@google.com> References: <20170810172615.51965-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC v2 07/23] x86: relocate_kernel - Adapt assembly for PIE support X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index 307d3bac5f04..2ecbdcbe985b 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -200,9 +200,11 @@ identity_mapped: movq %rax, %cr3 lea PAGE_SIZE(%r8), %rsp call swap_pages - movq $virtual_mapped, %rax - pushq %rax - ret + jmp *virtual_mapped_addr(%rip) + + /* Absolute value for PIE support */ +virtual_mapped_addr: + .quad virtual_mapped virtual_mapped: movq RSP(%r8), %rsp
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier <thgarnie@google.com> --- arch/x86/kernel/relocate_kernel_64.S | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)